Spawn actor and initialyse it

Hi, I've been playing with gamesalad for mac and I would like to know if it's posible to spawn an actor and pass it some parameters on the same time.
Thanks for help.

Comments

  • ShmirlyWhirlShmirlyWhirl Member Posts: 189
    Indeed it is.

    Just have a series of Change Attributes at the top of the actor being spawned. That way, as soon as it spawns, it will get all the proper parameters before doing any calculations.
  • sparkaniasparkania Member, PRO Posts: 300
    just add the parameters you want to the Prototype of the actor, and when it's spawned, it'll come out swinging!!
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    An example of this is to have a counter that increments each time an actor is spawned and then the actor "grabs" that counter as its own:

    Spawner actor:
    Change attribute game.counter to game.counter+1
    Spawn actor [actor name]

    Spawned actor:
    Change attribute self.Number to game.counter


    But this can also be done with table values. You could have the rows of a table be:
    H
    E
    L
    L
    O

    And then when the counter increments as above, you would have:

    Spawned actor
    Change attribute self.Letter to tableCellValue(TableName,game.counter,1)
    Change self.Image to self.Letter

    If you have images in your Library named H.png, E.png, L.png, and O.png, then the code above will spawn actors that spell out HELLO.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • r0bb12r0bb12 Member Posts: 2
    I made it, thanks a lot
Sign In or Register to comment.