GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Positioning many actors by coordinates

Hello
Does anyone know how I could put a lot of small actors on the screen. I want to make a forest with a lot of trees.

Comments

  • jordanptjordanpt Posts: 3Member
    I should probably be more clear. My tree actors are 10px X10px. I want about 5px space between them over entire level basically. Even if I wanted to manually move 100+ actors to correct spot It is difficult to pick up small actors. It also seems difficult to get them exactly in the right spot without seeing a grid on the screen or something. Is there a way to say spawn actor at 1,1 and 3,3 and 5,5 ect....
  • KevinCrossKevinCross London, UKPosts: 1,893Member
    edited September 2013
    Take a look at the Replicate behaviour. Place an actor on your scene, add a replicate behaviour to it and it will do exactly that, replicate itself in a line x amount of times.

    For a 10x10 actor with 5px gap it would be:

    Replicate:
    Direction: 0, Copies: 50, Spacing: 15

    That will copy 50 of them along one line.

    You could also achieve a more grid like layout with timers and/or loops but you may find that they'll be slow with that many actors.
  • jordanptjordanpt Posts: 3Member
    Thanks for the suggestion I just tried replicate, It worked great except the only actor that I can destroy now is the original one that the others were replicated from.
  • KevinCrossKevinCross London, UKPosts: 1,893Member
    Oh right, I've never really used Replicate, I just know what it does. One suggestion would be with a timer as a loop, you can create loops without timers, but I've not found a loop or timer that works fast enough, so you may find a 100 odd actors spawning in a loop noticeably slow.

    Perhaps someone will have a better suggestion for you.
  • -Timo--Timo- Posts: 2,313Member
    edited September 2013
    Maybe something like
    If self.position.x < 1024 (or something like that)
    Spawn actor offset x 15
    I am not sure if this can help as i never tried it and can lagg a lot
  • quantumsheepquantumsheep Posts: 8,188Member
    Try the attached file. It uses a table to position actors. I've included some notes which hopefully explain how it works.

    I'm sure there are faster/better ways, but it would solve your immediate problem maybe?

    Just make sure you have a large enough 'staging area' to put all the trees in before they move!

    Hope it helps!

    QS :D

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: http://www.quantum-sheep.com

Sign In or Register to comment.