Question

Can't seem to find any solution to my problem right now. I've seen some topics with 2d array undefined causing this error. here's the little code (fyi it's supposed to code an 2d array for my isometric engine)

public function collisionTest(coordinate:Point):Boolean {
var TableauCollision:Array = new Array();
            for (var spriteForX:int = 0; spriteForX < 29; spriteForX++)      {
                TableauCollision[spriteForX] = new Array();
                for (var spriteForY:int = 0; spriteForY < 29; spriteForY++) {
                TableauCollision[spriteForX][spriteForY] = 0;   
                }
            }
trace(TableauCollision[coordinate.x][coordinate.y]);
if (TableauCollision[coordinate.x][coordinate.y] == -1){
return (true);
}
return (false);
}

If i want a return for TableauCollision[coordinate.x] it's okay. But if i ask for TableauCollision[coordinate.x][coordinate.y] : error 1010, something isn't defined.

Thank you very very much for your help, since i know this topic has already been treated.

John, France.

Était-ce utile?

La solution 2

Okay guys I solved the problem. Couldn't tell what it was. Changed the architecture of my program, works better. And is cleaner. Thank you.

Autres conseils

change this:

for (var spriteForY:int = 0; spriteForY < 29; spriteForY++) {
  TableauCollision[spriteForX][spriteForY] = 0;   
}

to this:

for (var spriteForY:int = 0; spriteForY < 29; spriteForY++) {
  TableauCollision[spriteForX].push(0);   
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top