Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - xhunterko

Pages: [1] 2 3 ... 23
1
help / Re: Camera Swap(solved)
« on: Wed, Feb 27, 2013 »
Fixed it.

I did this instead:

Code: [Select]
{
camSettingsA = background.x;
camSettingsB = background.y;
camSettingsC = background.width;
camSettingsD = background.height;
cam1.bounds = new FlxRect(camSettingsA,camSettingsB,camSettingsC,camSettingsD);

}

if (_player.overlaps(janitorCloset))
{
camSettingsA = janitorCloset.x;
camSettingsB = janitorCloset.y;
camSettingsC = janitorCloset.width;
camSettingsD = janitorCloset.height;
cam1.bounds = new FlxRect(camSettingsA,camSettingsB,camSettingsC,camSettingsD);

}

Hopefully that shouldn't cause any problems.

2
help / Camera Swap
« on: Wed, Feb 27, 2013 »
Hey there!

I'm not too keen on deciphering documentation docs and I've not seen this posted here yet.

What I'm trying to do is switch a camera's settings when the player walks over a sprite. So, if a player is in a room, the camera scrolls and focuses around that room. If the player switches to another room, the camera scrolls and focuses around that room instead.

Here's what I'm trying to do code-wise:

Code: [Select]
package com
{
import org.flixel.*;
import org.flixel.plugin.photonstorm.*;
import flash.geom.Rectangle;

public class StationState extends FlxState
{

//Mouse
public var mouseCon:FlxSprite;

public var hbar:HealthBlock;

public var backdrop:FlxGroup;
public var background:FlxSprite;
public var janitorCloset:FlxSprite;

public var _player:PlayerInspector;
public var cam1:FlxCamera;
public var cam2:FlxCamera;

public var wallN:FlxTileblock;
public var wallW:FlxTileblock;
public var wallE:FlxTileblock;
public var wallS:FlxTileblock
public var wallz:FlxGroup;

public var camSettingsA:int;
public var camSettingsB:int;
public var camSettingsC:int;
public var camSettingsD:int;

override public function create():void
{
wallz = new FlxGroup;

FlxG.bgColor = 0xff000000;
background = new FlxSprite(0, 0);
background.makeGraphic(740, 1440, 0xff888888);
add(background);

janitorCloset = new FlxSprite(720, 0);
janitorCloset.makeGraphic(220, 1440, 0xff808080);
add(janitorCloset);

camSettingsA = background.x;
camSettingsB = background.y;
camSettingsC = background.width;
camSettingsD = background.height;


wallE = new FlxTileblock(0, 0, 16, 1440);
wallE.makeGraphic(16, 1440, 0xffD70000);
add(wallE);

wallz.add(wallE);
add(wallz);

_player = new PlayerInspector(120, 62);
add(_player);

//Camera 1
cam1 = new FlxCamera(0, 0, FlxG.width, FlxG.height);
FlxG.resetCameras(cam1);
cam1.follow(_player, FlxCamera.STYLE_TOPDOWN_TIGHT);
FlxG.worldBounds = new FlxRect(camSettingsA,camSettingsB,camSettingsC,camSettingsD);
cam1.bounds = new FlxRect(camSettingsA,camSettingsB,camSettingsC,camSettingsD);

FlxG.camera.follow(_player, FlxCamera.STYLE_TOPDOWN);
add(cam1);





FlxG.mouse.show();
mouseCon = new FlxSprite(0, 0);
mouseCon.makeGraphic(24, 32, 0xff400040);
mouseCon.x = mouseCon.y = 0;
mouseCon.visible = false;
add(mouseCon);


}
//
override public function update():void
{


if (_player.overlaps(background))
{
camSettingsA = background.x;
camSettingsB = background.y;
camSettingsC = background.width;
camSettingsD = background.height;
}

if (_player.overlaps(janitorCloset))
{
camSettingsA = janitorCloset.x;
camSettingsB = janitorCloset.y;
camSettingsC = janitorCloset.width;
camSettingsD = janitorCloset.height;
}

//Debug



super.update();



if (mouseCon.x != FlxG.mouse.x)
{
mouseCon.x = FlxG.mouse.x;
}
if (mouseCon.y != FlxG.mouse.y)
{
mouseCon.y = FlxG.mouse.y;
}

FlxG.collide(_player, wallz);


}




override public function destroy():void
{
// Important! Clear out the plugin, otherwise resources will get messed right up after a while
FlxSpecialFX.clear();

super.destroy();
}



}
}


I don't know why it's not working. But it really seems like it should. Any idea what I'm doing wrong here?

3
releases / Re: Health Bar Variant
« on: Tue, Jan 1, 2013 »
Heh, nope, those were mine that I added to hopefully explain some things. Thanks for clearing that up though!

4
releases / Health Bar Variant
« on: Tue, Jan 1, 2013 »
I was working on a project and needed a zelda-like health bar for my game. I tried using the Power tools cause I remember it having a similar funtion. However, I couldn't get it to behave right. So. I remember playing a Ludum Dare game that had a similar mechanic. So I found it and dug through the source til I found what I needed.

The heart meter:
Code: [Select]
package com
{
import org.flixel.*;
//Kuroki

public class HealthBlock extends FlxSprite
{

[Embed(source='../../data/healthBlock.png')] public var ImgHealth:Class;
public var posX:int;

public function  HealthBlock(X:int, Y:int):void
{
super(X, Y);
loadGraphic(ImgHealth, false, false, 16, 16);
//makeGraphic(16, 16, 0xffFF0000, false, "healthBlock");
posX = X;
}



override public function update():void
{
super.update();
}

override public function draw():void {
//var center:int = FlxG.width ;
                        //Here is where you set the player's health initially
var hearts:int = Registry.health;
                        //The original width of the sprite
var width:int = 16 * hearts + 1;

//y = 229;
frame = 0;
for (var i:uint = 0; i < hearts; i++) {
//x = center - width  + i * 10;
                               //I believe this is the space from the start x, to the next hear's x, if you want spacing between your hearts
x = posX + i *22;
if (Registry.health < i + 1) {
                                        //Er, your guess is as good as mine. 
frame = 1;
}

super.draw();
}
}


}
}



Playstate:
Code: [Select]
//This is how I call it
package com
{
import org.flixel.*;
import org.flixel.plugin.photonstorm.*;
import org.flixel.plugin.photonstorm.FX.StarfieldFX;
import flash.geom.Rectangle;

public class EarthState2 extends FlxState
{
//Music
//[Embed(source= '../../Music/DeadlierWindmills.mp3')] public var AmbMus1:Class;


public var playNow:FlxAdventureButton;

//Mouse
public var mouseCon:FlxSprite;

//Title
public var t:FlxText;

//Tiled background
public var background:FlxSprite;

public var pickBox:FlxAdventureButton;

private var stars:FlxSprite;
private var starfield:StarfieldFX;

public var _earth:Earth;

//The heart meter and it's text box
public var healthG:FlxText = new FlxText(16,0,400,"Health 2:",false);
public var hbar:HealthBlock;

override public function create():void
{
// If the Plugin isn't already in use, we add it here
if (FlxG.getPlugin(FlxScreenGrab) == null)
{
FlxG.addPlugin(new FlxScreenGrab);
}
if (FlxG.getPlugin(FlxSpecialFX) == null)
{
FlxG.addPlugin(new FlxSpecialFX);
}

starfield = FlxSpecialFX.starfield();
stars = starfield.create(0, 0, 640, 480, 256);
add(stars);


FlxG.bgColor = 0xffFFFFFF;

_earth = new Earth(FlxG.width/2-37, FlxG.height/2-37);
add(_earth);

//Health bar
healthG.size = 18;
add(healthG);

//healthG.x *2 + 34,0
//The heart meter attached to it's text box
hbar = new HealthBlock(healthG.x * 2 + 34, 0);
add(hbar);


mouseCon = new FlxSprite(0, 0);
mouseCon.makeGraphic(16, 16, 0xffFFFFFF);
mouseCon.x = mouseCon.y = 1;
//mouseCon.visible = false;
add(mouseCon);

if (Registry.level == 2)
{



}


}
//
override public function update():void
{
//Any action where the player would lose health
if (FlxG.mouse.justPressed())
{

Registry.health--;

}
if(FlxG.keys.any())
{

FlxG.switchState(new EarthState2());
}

super.update();


if (mouseCon.x != FlxG.mouse.x)
{
mouseCon.x = FlxG.mouse.x;
}
if (mouseCon.y != FlxG.mouse.y)
{
mouseCon.y = FlxG.mouse.y;
}


}



}
}

The registry is just your typical registry file. You could probably do without but I don't reccomend it. You can find out how to set one up here: http://www.photonstorm.com/archives/1136/flash-game-dev-tip-1-creating-a-cross-game-communications-structure

Very handy and very easy to do! So I thought I'd share it here.

Originally written by: @arkeus for Arzea for Ludum Dare 22

Enjoy!

5
releases / Re: Lightning class [CAUTION!]
« on: Sat, Dec 29, 2012 »
This is cool! I was hoping some other people would find a use for this too!

6
help / Re: Weird Bug [solved]
« on: Tue, Oct 16, 2012 »
I should mention that I have this solved I think. I can get a number from the registry object. But, I have to pass it to values instead. And then create the instances outside of the registry ifs. Then where I would put the cell type number, I have to put the value name instead. It works. But I still don't know why I have to do it this way. Shrugs.

7
Where would I put that at?

8
help / Weird Bug [solved]
« on: Wed, Oct 10, 2012 »
Okay. So I've been trying to get level loading working and I think I did the other night. So I take a nap, get up, and suddenly everything is broken. In my game, you have to correct a cell patern by switching a cell in the playfield with a cell in the inventory. If the two are compatible, the cell will switch to something else. Once you've corrected the sequence, a next level button will appear and you can go to the next cell sequences. There's a problem.

There are currently 4 levels. I'm using one file to load multiple levels, and a Registry object to hold the level number. When the player hits the next level button, the frame goes back to itself, and then arranges whatever cells in a pattern based on the registry number. The error occurs only after I go from level 1 to level 2. Not from level whatever to level whatever. And I don't know if it's level 1 or 2 that's the problem, cause going from level 2 to 3 (or any other level) is fine.

So, here's the error Flash Develop is throwing at me:

Code: [Select]
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at com::GradStudentStage/update()
at org.flixel::FlxGame/update()
at org.flixel::FlxGame/step()
at org.flixel::FlxGame/onEnterFrame()

Which, I don't know why. Cause I have, if Registry is 1, do things to create the level. And I have if Registry is 2, do things to create level. I don't know what's causing that. Here's the code for the, stage:

//It's rather long, sorry bout that. I've made a comment in there about where the error occurs.
Code: [Select]
package com
{
import flash.accessibility.ISimpleTextSelection;
import flash.display.InteractiveObject;
import org.flixel.*;
import org.flixel.plugin.photonstorm.*;
import org.flixel.plugin.photonstorm.FX.SineWaveFX;
import flash.geom.Rectangle;
import flash.display.Graphics;

/**
* Evolution!!!vvvv
*/

public class GradStudentStage extends FlxState
{

//Embeds
[Embed(source= '../../data/comoFin.mp3')] public var SndHit:Class;
[Embed(source= '../../data/errorFin.mp3')] public var SndHit2:Class;

//privvate/public vars

//Pause
public var paused:FlxPaused;

//Tutorial Mode
public var tutorialMode:FlxTutorialSession;

//Gui eye group
public var guiGroup:Gui;

//Inventory group
public var inventoryGroup:FlxGroup;


public var hp:FlxHelpBox;

//Cell inventory
public var invCellA:FlxAdventureButton;
public var invCellB:FlxAdventureButton;
public var invCellC:FlxAdventureButton;
public var invCellD:FlxAdventureButton;

//the help
public var click1:FlxAdventureButton;
public var click2:FlxAdventureButton;

//Next screen
public var nextClick:FlxAdventureButton;



//Grid cells
public var gcell1:RandomCell;
public var gcell2:RandomCell;
public var gcell3:RandomCell;
public var gcell4:RandomCell;
public var gcell5:RandomCell;
public var gcell6:RandomCell;

public var gridGroup:FlxGroup;

//Question Block
public var qblock:guiQuestionBlock;

//Hand hacked mouse
public var mouseCon:FlxSprite;

//Backscreen
private var mouseScreen:FlxSprite;
//
//Moves
public var moves:int;
public var moveGui:FlxText;
public var moveGuiNum:FlxText;
//Par
public var par:int;
public var parGui:FlxText;
public var parGuiNum:FlxText;

public var flashfx:FilterSprite;

//Testing board object
//This replaces all the playfield object placing
public var board:BoardState;

//Player's completion for win condition for multiple cells
public var winIt:uint;

override public function create():void
{
//Stage layout
/**
* Steps for a level:
* Set the par for each level.
* Set the hint for each level.
* Set the needed cell changes for each l.-
* Create level by registry number.
* Check to see if win condition met.
* Display next level button.
* Set the registry number when the next level button is clicked.
* Repeat for each level.
*
*/

// If the Plugin isn't already in use, we add it here
if (FlxG.getPlugin(FlxScreenGrab) == null)
{
FlxG.addPlugin(new FlxScreenGrab);
}

// Define our hotkey (string value taken from FlxG.keys) the parameters simply say "save it right away" and "hide the mouse first"
FlxScreenGrab.defineHotKey("F1", true, true);

//FlxG.mouse.show();

if (Registry.level >= 1)
{
board = new BoardState(46, 46);
//board.visible = false;
add(board);
}



//Bullet time effect??
//FlxG.bgColor = 0xff9FB85;
mouseScreen = new FlxSprite(0, 0);
mouseScreen.makeGraphic(640, 416, 0x00000000);
add(mouseScreen);

FlxG.bgColor = 0xffC0C0C0;

guiGroup = new Gui(160,416);
add(guiGroup);



//Help
//Hint Box
qblock = new guiQuestionBlock(608, 0);
add(qblock);

//Cell grid
gridGroup = new FlxGroup();
add(gridGroup);

//Inventory Row
inventoryGroup = new FlxGroup();

invCellA = new FlxAdventureButton(192, 432, 32, 32, "");
invCellA.enabled = false;
invCellA.visible = false;
invCellA._bg.color = 0xffFFFFFF;
add(invCellA);

invCellB = new FlxAdventureButton(invCellA._bg.x + 64, 432, 32, 32, "");
invCellB.enabled = false;
invCellB.visible = false;
add(invCellB);

invCellC = new FlxAdventureButton(invCellB._bg.x + 80, 432, 32, 32, "");
invCellC.enabled = false;
invCellC.visible = false;
add(invCellC);

invCellD = new FlxAdventureButton(invCellC._bg.x+64, 432, 32, 32, "");
invCellD.enabled = false;
invCellD.visible = false;
add(invCellD);

//Adding helper text per stage
var t:FlxText;
t = new FlxText(162, 396,400,"Needed:");
t.size = 16;
t.alignment = "left";
t.color = 0xffFF0000;
add(t);

//Tell the player what they need to fix
//
var miniHelp:MiniCell;
var miniHelpB:MiniCell;
if (Registry.level == 1)
{

miniHelp = new MiniCell(invCellB.px, t.y+8);
miniHelp.distributionp = 1;
add(miniHelp);
}
//
if (Registry.level == 2)
{

miniHelp = new MiniCell(invCellB.px, t.y+8);
miniHelp.distributionp = 1;
add(miniHelp);
}
//
if (Registry.level == 3)
{

miniHelp = new MiniCell(invCellB.px, t.y+8);
miniHelp.distributionp = 0;
add(miniHelp);

miniHelpB = new MiniCell(invCellB.px+32, t.y+8);
miniHelpB.distributionp = 1;
add(miniHelpB);


}
//
if (Registry.level == 4)
{

miniHelp = new MiniCell(invCellB.px, t.y+8);
miniHelp.distributionp = 0;
add(miniHelp);

miniHelpB = new MiniCell(invCellB.px+32, t.y+8);
miniHelpB.distributionp = 0;
add(miniHelpB);


}
//

//Moves
moveGui = new FlxText(0,0,200,"Moves:")
moveGui.size = 16;
moveGui.alignment = "left";
moveGui.color = 0xffFF0000;
add(moveGui);

//Just make them all transparent in one line shall we?
invCellA._bg.alpha = 0.45;
invCellB._bg.alpha = 0.45;
invCellC._bg.alpha = 0.45;
invCellD._bg.alpha = 0.45;



//to next level
nextClick = new FlxAdventureButton(536, 416, 32, 32, "Click to go to Next");
add(nextClick)

//Levels!
if (Registry.level == 1)
{
//Adding the play pieces
//Tutorial pieces are set board.grBx.members[2]
gcell1 = new RandomCell(board.grBx.members[11].x, board.grBx.members[11].y);
gcell1.distributionp = 0;
add(gcell1);

gcell2 = new RandomCell(board.grBx.members[13].x, board.grBx.members[13].y);
gcell2.distributionp = 0;
//gcell2.visible = false;
add(gcell2);

par = 2;
}

if (Registry.level == 2)
{
//Adding the play pieces
gcell1 = new RandomCell(board.grBx.members[11].x, board.grBx.members[11].y);
gcell1.distributionp = 0;
add(gcell1);

gcell2 = new RandomCell(board.grBx.members[2].x, board.grBx.members[2].y);
gcell2.distributionp = 3;
add(gcell2);

gcell3 = new RandomCell(board.grBx.members[8].x, board.grBx.members[8].y);
gcell3.distributionp = 0;
add(gcell3);

par = 3;
}

if (Registry.level == 3)
{
//Adding the play pieces
gcell1 = new RandomCell(board.grBx.members[0].x, board.grBx.members[0].y);
gcell1.distributionp = 3;
add(gcell1);

gcell2 = new RandomCell(board.grBx.members[18].x, board.grBx.members[18].y);
gcell2.distributionp = 0;
add(gcell2);

gcell3 = new RandomCell(board.grBx.members[19].x, board.grBx.members[19].y);
gcell3.distributionp = 3;
add(gcell3);

gcell4 = new RandomCell(board.grBx.members[14].x, board.grBx.members[14].y);
gcell4.distributionp = 0;
add(gcell4);




par = 4;
}

if (Registry.level == 4)
{
//Adding the play pieces
gcell1 = new RandomCell(board.grBx.members[6].x, board.grBx.members[6].y);
gcell1.distributionp = 0;
add(gcell1);

gcell2 = new RandomCell(board.grBx.members[7].x, board.grBx.members[7].y);
gcell2.distributionp = 3;
add(gcell2);

gcell3 = new RandomCell(board.grBx.members[2].x, board.grBx.members[2].y);
gcell3.distributionp = 3;
add(gcell3);

gcell4 = new RandomCell(board.grBx.members[8].x, board.grBx.members[8].y);
gcell4.distributionp = 0;
add(gcell4);

gcell5 = new RandomCell(board.grBx.members[12].x, board.grBx.members[12].y);
gcell5.distributionp = 1;
add(gcell5);



par = 3;
}


//Par
//Unlike moves, par is permanent
parGui = new FlxText(120,0,200,"Par:  02")
parGui.size = 16;
parGui.alignment = "left";
parGui.color = 0xffFF0000;
add(parGui);



//Cell lines
//mouseScreen.drawLine(gcell1.x+4, gcell1.y+32, gcell2.x+32, gcell2.y+32, 0xff000000,2);
//mouseScreen.draw();



gridGroup.add(gcell1);
gridGroup.add(gcell2);
gridGroup.add(gcell3);
gridGroup.add(gcell4);
gridGroup.add(gcell5);
gridGroup.add(gcell6);



//A flash effect for a hint
flashfx = new FilterSprite();
//flashfx.x = gcell2.x;
//flashfx.y = gcell2.y;
flashfx.makeGraphic(64, 64, 0xff8080FF);
flashfx.activateFilter(FilterSprite.FILTER_COLOR);
flashfx.alpha = 0.85;
flashfx.visible = false;
add(flashfx);





//To be on top of almost everything else
paused = new FlxPaused;
//add(paused);



mouseCon = new FlxSprite(0, 0);
mouseCon.makeGraphic(16, 16, 0xff400040);
mouseCon.x = mouseCon.y = 0;
//mouseCon.visible = false;
add(mouseCon);





}
 
override public function update():void
{


//The pause menu is popped up here
if (!paused.showing)
{


if (mouseCon.overlaps(invCellA) && FlxG.mouse.justPressed())
{
invCellA.enabled = true;
invCellA.visible = true;
}

if (mouseCon.overlaps(invCellB) && FlxG.mouse.justPressed())
{
invCellB.enabled = true;
invCellB.visible = true;
}


if (mouseCon.overlaps(invCellC) && FlxG.mouse.justPressed())
{

invCellC.enabled = true;
invCellC.visible = true;
}

if (mouseCon.overlaps(invCellD) && FlxG.mouse.justPressed())
{
invCellD.enabled = true;
invCellD.visible = true;
}

/*
if (mouseCon.overlaps(board.boxes[1]) && FlxG.mouse.justPressed())
{
board.right._bg.flicker(4);

}
*/






//Pieces selected and merging them with other parts
//if a piece is selected and the inventory piece a is picked

//Selectioin cell A
if (invCellA.enabled == true )
{
for each (var oneA:RandomCell in gridGroup.members)
{
//Cell formulaes
//a+a
if (FlxG.overlap(mouseCon, oneA) && oneA.distributionp == 1 && FlxG.mouse.justPressed() )
{
oneA.distributionp = 2;


} else if (!FlxG.overlap(mouseCon, invCellA) && FlxG.mouse.justPressed() )
{
invCellA.visible = false;
invCellA.enabled = false;
}
//
}

}


//Selection Cell B
if (invCellB.enabled == true)
{
for each (var twoA:RandomCell in gridGroup.members)
{
//Cell formulaes

if (FlxG.overlap(mouseCon, twoA) && twoA.distributionp == 2 && FlxG.mouse.justPressed())
{
twoA.distributionp = 3;


} else if (!FlxG.overlap(mouseCon, invCellB) && FlxG.mouse.justPressed())
{
invCellB.visible = false;
invCellB.enabled = false;

}
//
}
}

  //Selection Cell C
if (invCellC.enabled == true)
{
for each (var threeA:RandomCell in gridGroup.members)
{
//Cell formulaes

if (FlxG.overlap(mouseCon, threeA) && threeA.distributionp == 3 && FlxG.mouse.justPressed())
{
threeA.distributionp = 0;


} else if (!FlxG.overlap(mouseCon, invCellC) && FlxG.mouse.justPressed() )
{
invCellC.visible = false;
invCellC.enabled = false;
}
//
}
}

   //Selection Cell D
if (invCellD.enabled == true)
{
for each (var fourA:RandomCell in gridGroup.members)
{
//Cell formulaes

if (FlxG.overlap(mouseCon, fourA) && fourA.distributionp == 0 && FlxG.mouse.justPressed())
{
fourA.distributionp = 1;


} else if (!FlxG.overlap(mouseCon, invCellD) && FlxG.mouse.justPressed() )
{
invCellD.visible = false;
invCellD.enabled = false;
}
//
}
}


//Hint
//LEVEL 1
if (Registry.level == 1)
{
if(FlxG.mouse.justPressed() && mouseCon.overlaps(qblock))
{
flashfx.visible = true;
} else if (FlxG.mouse.justReleased())
{
flashfx.visible = false;
}
}

//Next level
if (Registry.level == 1)
{
if (FlxG.overlap(mouseCon, nextClick) && FlxG.mouse.justPressed())
{

//win condition
if (gcell2.distributionp == 1)
{
//Here is where it throws the error. But it doesn't throw it anywhere else I do this. Why?
Registry.level = 2;
FlxG.switchState(new GradStudentStage());

} else
{

nextClick.visible = false;//
}
}
if (gcell2.distributionp != 1)
{

nextClick.visible = false;//
} else
{

nextClick.visible = true;
}
}
//LEVEL 2 check
if (Registry.level == 2)
{
if (FlxG.overlap(mouseCon, nextClick) && FlxG.mouse.justPressed())
{

//win condition
if (gcell2.distributionp == 1)
{
Registry.level = 3;
FlxG.switchState(new GradStudentStage());

} else
{

nextClick.visible = false;//
}
}
if (gcell3.distributionp != 1)
{

nextClick.visible = false;//
} else
{

nextClick.visible = true;
}
}

//LEVEL 3 check
if (Registry.level == 3)
{
//Different condition for 2 cells
if (gcell3.distributionp == 1 && gcell1.distributionp == 0)
{
winIt = 1;
}

if (winIt == 1)
{

nextClick.visible = true;//
} else
{
nextClick.visible = false;
}


if (FlxG.overlap(mouseCon, nextClick) && FlxG.mouse.justPressed())
{

//win condition
if (winIt == 1)
{
Registry.level = 4;
winIt = 0;
FlxG.switchState(new GradStudentStage());

} else
{

nextClick.visible = false;//
}
}
if (winIt != 1)
{

nextClick.visible = false;//
} else
{

nextClick.visible = true;
}
}



//LEVEL 4 check
if (Registry.level == 4)
{
//Different condition for 2 cells
if (gcell3.distributionp == 0 && gcell5.distributionp == 0)
{
winIt = 1;
}

if (winIt == 1)
{

nextClick.visible = true;//
} else
{
nextClick.visible = false;
}


if (FlxG.overlap(mouseCon, nextClick) && FlxG.mouse.justPressed())
{

//win condition
if (winIt == 1)
{
Registry.level = 1;
FlxG.switchState(new GradStudentStage());

} else
{

nextClick.visible = false;//
}
}
if (winIt != 1)
{

nextClick.visible = false;//
} else
{

nextClick.visible = true;
}
}

//FlxG.log(Registry.level);
//trace("reg" + Registry.level);
super.update();



if (mouseCon.x != FlxG.mouse.x)
{
mouseCon.x = FlxG.mouse.x;
}
if (mouseCon.y != FlxG.mouse.y)
{
mouseCon.y = FlxG.mouse.y;
}

if (FlxG.keys.ONE)
{
Registry.level = 1;
FlxG.switchState(new GradStudentStage());

}
if (FlxG.keys.TWO)
{
Registry.level = 2;
FlxG.switchState(new GradStudentStage());

}
if (FlxG.keys.THREE)
{
Registry.level = 3;
FlxG.switchState(new GradStudentStage());

}
if (FlxG.keys.FOUR)
{
Registry.level = 4;
FlxG.switchState(new GradStudentStage());

}


} else
{

if (mouseCon.x != FlxG.mouse.x)
{
mouseCon.x = FlxG.mouse.x;
}
if (mouseCon.y != FlxG.mouse.y)
{
mouseCon.y = FlxG.mouse.y;
}



paused.update();
}



}


override public function destroy():void
{
// Important! Clear out the plugin, otherwise resources will get messed right up after a while
FlxSpecialFX.clear();
super.destroy();
}

//Example call back function. could be sound, or anything
public function dialogKill():void
{
//_player.kill();
//header.kill();
//headerTxt.kill();
}
//Snap to mouse
//Mouse snapping!
protected function Snap(Sprite1:FlxSprite,Sprite2:FlxSprite):void
{
if (Sprite1.x != Sprite2.x-12)
{
Sprite1.x = Sprite2.x-12;
}
if (Sprite1.y != Sprite2.y-10)
{
Sprite1.y = Sprite2.y - 10;
}

}

}
}


Any ideas? Thanks in advance!

9
help / Re: Behave array!
« on: Wed, Oct 3, 2012 »
Hey again!

Just wanted to say thanks for helping out. I finally got it to work with a custom object last night and also took a second look at it. Apparently, my original objects are not evenly spaced. At least, I don't think so. But these in this structure are. So thanks again!

10
help / Re: Behave array!
« on: Fri, Sep 28, 2012 »
Quote
Your blue boxes are 64x64, spaced apart 120 on the x-axis and 90 on y-axis.
Your green boxes are 62x62, spaced apart 128 on the x-axis and 90 on y-axis.

Okay. But I did that to see if I was losing the sprites behind the originals and not seeing them. I just couldn't see the originals so I changed the background color. If they were the same size as the originals, the exact same thing still happens. Regardless of size. So I dunno what's causing that. They are supposed to spaced apart like the originals are though. I thought they were 64x64 but they are 128 pixels away and 90 pixels down from each other. I got the numbers wrong in the first post my bad. But I didn't know you could do that with groups. I'll see about trying something like you suggested there. Any ideas on what might be wrong with the grid?

11
help / Re: Behave array!
« on: Fri, Sep 28, 2012 »
Hey thanks!

While that does work. It has it's own problems too.


The blue boxes are the ones I hand coded in and the green boxes are created via array.

Notice that a lot of the spacing is off for some of them. What causes that? Also. I need to get them into an array so that in the playstate I can go board.boxes[1].x. Or does flxgroup do something like that?

12
help / Behave array!
« on: Wed, Sep 26, 2012 »
Ugh.

I need to get this array to behave. I have one that creates a row of 5 sprites to show off an example of some filters. That single row array looks like this:

Code: [Select]

coins = new Array();

for (var i:int = 0; i < 6; i ++)
{
coins[i] = new FilterCoin();
//coins[i].y = 100;
coins[i].x = 20 + (i * 128);
add(coins[i]);
coins[i].play("spin");


}

Now. What I want to do, is create a 4 height by 5 wide array of objets that are 64x64 each and I want them placed like this: The first one is placed manually, then the next one in the row is 64 pixels away and so on. And the object below it is also 64 pixels. Now I have something from an arcanoid and minesweeper example that places an array of objects in a grid. Here is that one:

Code: [Select]
var bx:int = 10;
var by:int = 30;

var brickColours:Array = [ 0xffd03ad1, 0xfff75352, 0xfffd8014, 0xffff9024, 0xff05b320, 0xff6d65f6 ];

for (var y:int = 0; y < 6; y++)
{
for (var x:int = 0; x < 20; x++)
{
var tempBrick:FlxSprite = new FlxSprite(bx, by);
tempBrick.velocity.y = 2;
tempBrick.makeGraphic(15, 15, brickColours[y]);
tempBrick.immovable = true;
bricks.add(tempBrick);
bx += 15;
}

bx = 10;
by += 15;
}

I'm able to tweak the one above just a little bit. But I don't really understand it. How can I get an array to do what I described?

Thanks in advance!


13
help / Re: one color glowing in the dark?
« on: Thu, Sep 13, 2012 »
What he said. ^

Or you could try and combine the two. Here's the filter classes he was mentioning:

http://forums.flixel.org/index.php/topic,6448.0.html

Be sure to thank notsoftgames!

14
releases / Re: FlxTrail
« on: Fri, Aug 31, 2012 »
Sweet!

15
chat / Re: Our own collaboration board, thread, thing?
« on: Sun, Aug 19, 2012 »
Well, I meant like a general coboration board like tigsource does.

16
chat / Our own collaboration board, thread, thing?
« on: Tue, Aug 14, 2012 »
So, a couple of sites that I frequent have theirs. Yet I notice that a number of flixel users aren't on there. So I was wondering if we should start our own collaboration board to see if flixel users would want to work together? Especially since this is a pretty mellow site there might be some people wanting to work together on something. What does everybody else think?

17
chat / Trying to save memory with tile maps
« on: Sat, Jun 23, 2012 »
Hey guys!

I'm making a game with fairly large tile maps. From my experience, these take up a lot of memory. I've thought up of several ways to load maps but none of them are going to work I think.

Mostly because in the game, I want you to be able to ask: Can I lift a larg object, throw it from a distance, and it still hit a recycle object to generate cash with? I want to be able to say yes. But with the loading systems I've thought of I've not come up with a good solution.

However, I thought of something the other day.

Can I call collide on a tilemap, but just not draw it?

18
releases / Some Cool Filter Effects (from notsoftgames)
« on: Sun, Jun 17, 2012 »
Hey guys!

In most of my games, I want to be able to help the player figure out what to do by having an item or object that they can interact with glow. Now flash can do this. Flixel doesn't seem to play nicely with flash's filters. However, a conversation was going on on twitter and I noticed another game's screen shot. Now, I don't know if the game was a one shot deal or not, but I assumed that it was and asked the guy if he was going to open source it. He said no at first. But then not only provided the classes, but went the extra mile and provided a working code example in a playstate. How cool is that? He also said it was okay to post these here as well.

A brief explanation is that these classes extend flxsprite and flxtilemap. This also means that you can have them extend photonstorm's FlxExtendedSprite as well. How cool is that? Anyways, here's a playstated example with a registry source file thing going on.

There's only one or two small issues. When he sent me the example swf, it didn't work. When I compiled the code into flash develop, it ran fine. I also noticed that the sprites seemed to be cut off at the top and bottom. There's probably an easy fix for this and I'll or someone smarter will figure it out later. Other then that. Enjoy!

Quick link:
http://t.co/4o6lUxjE

Filter Sprite:
Code: [Select]
package
{
import flash.filters.BevelFilter;
import flash.filters.BlurFilter;
import flash.filters.ColorMatrixFilter;
import flash.filters.GlowFilter;
import flash.geom.Point;
import org.flixel.FlxSprite;

import org.flixel.plugin.photonstorm.*;
/**
* ...
* @author bignobody
*/
public class FilterSprite extends FlxExtendedSprite
{
//Static filters, so we use the same filters for every FilterSprite
public static var FILTERS:Array;
public static var FILTERPOINTS:Array;
// Some named indexes to make this a little more human friendly
public static var FILTER_COLOR:int = 0;
public static var FILTER_GLOW:int = 1;
public static var FILTER_BLUR:int = 2;
public static var FILTER_BEVEL:int = 3;

// the filters currently affecting this sprite.
protected var activeFilters:Array;
protected var activeFilterPoints:Array;


public function FilterSprite()
{
if (FilterSprite.FILTERS == null)
{
// if the filters don't exist yet, make 'em!
FilterSprite.initializeFilters();
}

// initialize the arrays
resetFilters();

super();
}

public static function initializeFilters():void
{
FILTERS = new Array();
FILTERPOINTS = new Array();

// For the colour filter, I'm just turning the brightness down 50%, but you can do lots of crazy cool stuff with this filter.
var bright:Number = 0.5;
var matrix:Array = new Array();
matrix = matrix.concat([bright, 0, 0, 0, 0]); // red
matrix = matrix.concat([0, bright, 0, 0, 0]); // green
matrix = matrix.concat([0, 0, bright, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha

FILTERS[FILTER_COLOR] = new ColorMatrixFilter(matrix);
FILTERPOINTS[FILTER_COLOR] = new Point( 0, 0);

// make the rest of our filters
FILTERS[FILTER_GLOW] = new GlowFilter(0xffffff, 1.0, 16, 16, 2, 1, false, false);
FILTERPOINTS[FILTER_GLOW] = new Point( -8, -8);
FILTERS[FILTER_BLUR] = new BlurFilter(4, 4, 1);
FILTERPOINTS[FILTER_BLUR] = new Point( -2, -2);
FILTERS[FILTER_BEVEL] = new BevelFilter(4, 45, 0xffffff, 1, 0, 0.75, 4, 4, 1, 1, "inner", false);
FILTERPOINTS[FILTER_BEVEL] = new Point( 0, 0);

}

public function resetFilters():void
{
// dump any references to existing filters
activeFilters = new Array();
activeFilterPoints = new Array();
}

public function activateFilter(filterType:int):void
{
if (filterType > -1 && filterType < FilterSprite.FILTERS.length)
{
// add the requested filter to this sprites active filters
activeFilters[activeFilters.length] = FilterSprite.FILTERS[filterType];
activeFilterPoints[activeFilterPoints.length] = FilterSprite.FILTERPOINTS[filterType];
}
}

// here's the Flixel integration!
// framePixels is the Bitmapdata that we can apply flash filters to.
// framePixels gets updated whenever the FlxSprite changes frames, so it seems like the best time to apply our filters
override protected function calcFrame():void
{
super.calcFrame();
if (activeFilters.length > 0)
{
// loop through all filters active on this sprite and apply them to the frame.
for (var i:int = 0; i < activeFilters.length; i ++)
{
if (framePixels != null)
{
// Apparently this is the inefficient way (internal copying), but if you want to add a seperate bitmap and handle it yourself, be my guest :D
framePixels.applyFilter( framePixels, framePixels.generateFilterRect(framePixels.rect, activeFilters[i]), activeFilterPoints[i], activeFilters[i]);
}
}
}
}

}

}

FilterTileMap:
Code: [Select]
package
{
import org.flixel.FlxTilemap;

/**
* ...
* @author bignobody
*/
public class FilterTileMap extends FlxTilemap
{
//Static filters, so we use the same filters for every FilterTileMap
// Alternatively, you could make a static Filters class that held a bunch of filter instances and use them everywhere...
public static var FILTERS:Array;
public static var FILTERPOINTS:Array;
// Some named indexes to make this a little more human friendly
public static var FILTER_COLOR:int = 0;
public static var FILTER_GLOW:int = 1;
public static var FILTER_BLUR:int = 2;
public static var FILTER_BEVEL:int = 3;

// active filters for this tilemap
protected var activeFilters:Array;
protected var activeFilterPoints:Array;

public function FilterTileMap()
{
if (FilterTileMap.FILTERS == null)
{
FilterTileMap.initializeFilters();
}
super();
resetFilters();
}

public static function initializeFilters():void
{
FILTERS = new Array();
FILTERPOINTS = new Array();

// For the colour filter, I'm just turning the brightness down 50%, but you can do lots of crazy cool stuff with this filter.
var bright:Number = 0.5;
var matrix:Array = new Array();
matrix = matrix.concat([bright, 0, 0, 0, 0]); // red
matrix = matrix.concat([0, bright, 0, 0, 0]); // green
matrix = matrix.concat([0, 0, bright, 0, 0]); // blue
matrix = matrix.concat([0, 0, 0, 1, 0]); // alpha

FILTERS[FILTER_COLOR] = new ColorMatrixFilter(matrix);
FILTERPOINTS[FILTER_COLOR] = new Point( 0, 0);

// make the rest of our filters
FILTERS[FILTER_GLOW] = new GlowFilter(0xffffff, 1.0, 16, 16, 2, 1, false, false);
FILTERPOINTS[FILTER_GLOW] = new Point( -8, -8);
FILTERS[FILTER_BLUR] = new BlurFilter(4, 4, 1);
FILTERPOINTS[FILTER_BLUR] = new Point( -2, -2);
FILTERS[FILTER_BEVEL] = new BevelFilter(4, 45, 0xffffff, 1, 0, 0.75, 4, 4, 1, 1, "inner", false);
FILTERPOINTS[FILTER_BEVEL] = new Point( 0, 0);

}

public function resetFilters():void
{
// dump any references to existing filters
activeFilters = new Array();
activeFilterPoints = new Array();
}

public function activateFilter(filterType:int):void
{
if (filterType > -1 && filterType < FilterTileMap.FILTERS.length)
{
// add the requested filter to this sprites active filters
activeFilters[activeFilters.length] = FilterTileMap.FILTERS[filterType];
activeFilterPoints[activeFilterPoints.length] = FilterTileMap.FILTERPOINTS[filterType];
}
}

// Here's the Flixel integration!
// drawTileMap stamps the visible section of the tilemap to the buffer, so we want to apply our filters right after that happens.
override protected function drawTilemap(Buffer:FlxTilemapBuffer, Camera:FlxCamera):void
{

super.drawTilemap(Buffer, Camera);

applyActiveFilters();
}

protected function applyActiveFilters():void
{
// _buffers is an internal array of FlxTilemapBuffer objects, which has the pixels we're filtering
for (var i:int = 0; i < _buffers.length; i ++)
{
if (_buffers[i] != null)
{
for (var f:int = 0; f < activeFilters.length; f ++)
{
_buffers[i].pixels.applyFilter(_buffers[i].pixels, _buffers[i].pixels.generateFilterRect(_buffers[i].pixels.rect, activeFilters[f]), activeFilterPoints[f], activeFilters[f]);
}
}
}
}
}

}

Filter State:
Code: [Select]
package
{
import org.flixel.FlxState;

/**
* ...
* @author bignobody
*/
public class FilterTestState extends FlxState
{

private var coins:Array;

public function FilterTestState()
{
coins = new Array();

for (var i:int = 0; i < 6; i ++)
{
coins[i] = new FilterCoin();
coins[i].y = 100;
coins[i].x = 20 + (i * 128);
add(coins[i]);
coins[i].play("spin");
}

coins[1].activateFilter(FilterSprite.FILTER_GLOW);
coins[2].activateFilter(FilterSprite.FILTER_BEVEL);
coins[3].activateFilter(FilterSprite.FILTER_BLUR);
coins[4].activateFilter(FilterSprite.FILTER_COLOR);
coins[5].activateFilter(FilterSprite.FILTER_BLUR);
coins[5].activateFilter(FilterSprite.FILTER_BEVEL);
coins[5].activateFilter(FilterSprite.FILTER_GLOW);
}

}

}

The resource file, coin file, and it's main file are easily understandable. But there are those in a nutshell. Also be sure and thank notsoftgames when you use them. I'd sure he'd appreciate it. Here's where you can do that:

Notsoftgames site:
http://www.notsoftgames.com/

Notsoftgames twitter:
https://twitter.com/notsoftgames

19
Cool!

Best place this into Release so it doesn't get lost easy. Looking forward to go through this more thoroughly when I get a second.

20
I'm pretty sure you can download Pixel Bender from adobe. And if you get it to work in 2.55 then if you don't mind would you let us know? Thanks!

Pages: [1] 2 3 ... 23