2 different enemy images?

ChirpinGamesChirpinGames Member, PRO Posts: 214
edited November -1 in Working with GS (Mac)
Hey all, just wondering if its possible to have an enemy spawner that after 4 secs randomly spawns one of two different images?

Comments

  • quantumsheepquantumsheep Member Posts: 8,188
    Yes, yes it is possible.

    Have a timer - as you suggested.
    Make an attribute - say 'Random Spawn'.

    When timer goes off
    Change attribute Random Spawn to Random (1,2)

    Then have a rule
    If attrubute Random Spawn = 1, then spawn actor type 1
    If attribute Random Spawn = 2, then spawn actor type 2

    That should do it.

    Hope that helps,

    QS :)

    Dr. Sam Beckett never returned home...
    Twitter: https://twitter.com/Quantum_Sheep
    Web: https://quantumsheep.itch.io

  • ChirpinGamesChirpinGames Member, PRO Posts: 214
    Fantastic thanks for the help!
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    How do I make a rule "If attrubute Random Spawn = 1, then spawn actor type 1"?

    I can only set true or false if I make a rule with attributes.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You need to use an integer Attribute. When you click the plus sign to add Attributes, make sure you choose Integer.

    You use it like this:

    Change Attribute
    self.myRandomImage to random(1,totalNumberofImages)

    Then some Rules like this:

    Rule
    When self.myRandomImage = 1
    Change Image To image1.png

    Rule
    When self.myRandomImage = 2
    Change Image To image2.png

    etc...

    Hope this helps!
    Joe
  • HunnenkoenigHunnenkoenig Member Posts: 1,173
    Super! It worked! Thanks!

    To be honest, I used this for spawning bonuses after a collision, but it works fine.

    When actor X collides with actor Y, actor Y drops a random bonus from a set of 3 possible bonuses.

    Works like a charm.
Sign In or Register to comment.