MC placed several times and given the same instance name?

Hi all, I'm pretty new to the code in flash.

I especially used to use object oriented programming, but in flash, I do everything in an image.

I'm a car game. A little style GTA, but very simple. You are a police car and chasing you a thief through a city.

The thief uses ground nodes to know where it can lead, and where he can turn.

Basically, here's the scene. I placed these objects directly on the stage and given some of them instance names. :

_________________________________

|      O

|  I have o

|            _______________________

|            |

|            |

|            |

|            |

|      ^     |

|      |     |

|     X     |

The is a MC named node_switch.

The O is the two objects of the same MC, who both are named node_stop

The X is the thief (mc), and it's driving up along the road.

When the thief strikes node_switch, it will look up, down, left and right if any node_stop is placed.

This is done with hitTestObject. the thief 'beams' invisible in 4 directions, inside it's MC.

The problem is as follows:

When several nodes are placed on the stage, the thief faces only one of them.

As I said, they have the same instance name.

Is there a way to be able to place them directly on the stage, give them all the same instance name and make a loop where it goes through each of them and check the collision?

Edit:

Or maybe it is possible to place them directly on the stage, give them the name of bodies such as 'node_switch01', 'node_switch02' and then check for them all at the same time in a loop for or in some other way? There will be a lot of knots, then...

If you name them all differently, you will have an easier time of it.  Loop through them with the naming convention, you suggested that you can use the notation of support, but it would be easier to get rid of zeros...

for (var i: uint = 1; i<=numNodes;>

{if (Thief.hitTestObject (this ["node_switch" + String (i)])}

don't go that way

}

}

Tags: Adobe Animate

Similar Questions

Maybe you are looking for