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 Member Posts: 3
    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, UKMember Posts: 1,894
    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 Member Posts: 3
    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, UKMember Posts: 1,894
    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- Member Posts: 2,313
    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 Member Posts: 8,188
    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: https://quantumsheep.itch.io

Sign In or Register to comment.