Get x-y co-ordinates of random actor

bigleaphr

  • Posts: 188
Get x-y co-ordinates of random actor alive in scene that has not been placed in the scene at start of the game, but created later on dynamically.

Any idea how?

captaincomic

  • *
  • Posts: 6108
I can think of two options:
1) You can use the "for each actor of type" loop to get actors created dynamically.
That's especially usuful if there is always only on actor of that type.

2) Remember the actor when you create it. Create an actor attribute in the behavior where you create your actor. Then, right after the "create actor type at ..." block, put "set YourActorAttribute to <Last Created Actor>". You can use this attribute in this behavior directly or if you need to access it from other behaviors, you can do it with messaging blocks.

bigleaphr

  • Posts: 188
Couldnt use actor of type since i have many actors of different type.

However the other option was around and got it to work with:

for each "actor of group" : "actors"

create new "actor of type" using x and y from "actor of group" from above

and a stop statement to end the loop.

Worked great - thnx again - my game is so close to done.

Even with the learning curve, this game has been made faster than a game on Adobe Flash Pro. Future games will be easier to edit since i will make this in the form of a module to recycle and use. In built API's are a deal sealer for Flash and iPhone.