need help with rondom spawner

good day i am new to gamesalad i am having with spawning actor in my game.i need someone to show me how to spawn random enemy actor or any actor to a particular location in my iphone portrait game in need the jail cell to spawn random in the middle left or right edges of the game .can someone help me please

Comments

  • NNterprisesNNterprises Member, PRO Posts: 387

    Lets say you have 3 enemies A, B, and C and you want to spawn them at specific locations.

    1. Create an integer attribute called RANDOM
    2. On any actor on your scene (that will not be destroyed) create a timer like this:
      ---Timer - Every 0.0 seconds, change Attribute RANDOM to random(1,3) (this will set your random value)
    3. Create another timer, Every X seconds,
      ---Create a rule, If attribute random = 3, spawn actor C, in position (X,Y) relative to scene.
      _____In the ELSE spot put another rule, If attribute random = 2, spawn actor B, in position (X,Y) relative to scene.
      ---_In the ELSE spot of that one just put spawn actor A, in position (X,Y) relative to scene.

    3 will spawn your actors repeatedly every X seconds at whatever X and Y positions you put for your iphone

  • SocksSocks London, UK.Member Posts: 12,822

    @NNterprises said:

    You don't really need to be generating a random value on every cycle, you can put it into your spawn timer.

    Timer, Every (whatever) seconds,
    --Change X to random(1,3)
    --If attribute X=1 spawn actor A
    ----Otherwise If attribute X=2 spawn actor B
    --------Otherwise spawn actor C

  • NNterprisesNNterprises Member, PRO Posts: 387

    Ahh true... good one @Socks

Sign In or Register to comment.