Continuing the discussion from New to FlashPunk, however have developed with AS3 before! :
Sorry for the double post guys!
I was wondering what the simplest way to create an array of the same block image and have them in my test world would be.
What I have so far creates the array and places the boxes in the world. However for some reason only the hit detection for one of the boxes is functioning properly.
TestWorld.as
for (var b:int = 0; b < 50; b++)
{
var space:int = 60;
GameVariables.blockLocation = [[b * space, FP.rand(FP.stage.height)]];
for (var c:int = 0; c < GameVariables.blockLocation.length; c++)
{
GameVariables.block1 = new Block();
this.add(GameVariables.block1);
GameVariables.block1.x = GameVariables.blockLocation[i][0];
GameVariables.block1.y = GameVariables.blockLocation[i][1];
}
}
This is my hero.as class
if (collide("block", x, y))
{
v.y = 0;
for (var c:int = 0; c < GameVariables.blockLocation.length; c++)
{
y = GameVariables.blockLocation[c][2] - height;
trace("colliding with " + GameVariables.blockLocation[c] [3]);
}
}
I feel like I am very close but am pretty draining I have been messing with the same few lines of codes for quite some time now!
Once again sorry for the double post! I thought I would at least keep it in the same thread.
It sounds like you probably want to look into the Grid class for collision, and the Tilemap class for displaying the objects. Both of these will afford you much greater performance as well as a lot less code.