PDA

View Full Version : tile based question


shieldsduncan
03-30-2003, 10:48 AM
Hi, I'm building a tyle based engine and I want to be able to do a hitTest dependant on which tile I am in at any give time.

The tile names are each called:

_level0.grid.celli_j

Where i is the column number and j is the row number.

eg

000{}00
0000000
0000000

This tyle ({}) would be called cell4_1

I have variables set to tell me which cell my character is in at any given time and I need to know how to write the script which would do a hitTest whilst he is in it without having to write a different line of code for each tile.

What I need is the syntax to do this:

if (character.hitTest(celli_j.objectName)){
do something;
}

Any help would be great,

Cheers

Billy T
03-30-2003, 02:09 PM
use two for loops - probably the same ones that you used you build your grid

eg

for(c=1;c<=columnNum;c++){
for(r=1;r<=rowNum;r++){
if (character.hitTest(["cell"+c+"_"+r].objectName)){
do something;
}
}
}

cheers