GameSalad

Howdy, Stranger!

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

increase speed after x seconds

Hello again,
so basically for 10 seconds I have actors moving down the screen (270 degrees) and they are at a speed of 150. What I am trying to do is increase the speed up to 200 after 10 seconds. how can I do this?

Comments

  • tatiangtatiang Posts: 11,525Member, Sous Chef, PRO, Senior Sous-Chef

    Use a timer to determine when 10 seconds have passed. Make sure that your speed value is an attribute rather than a constant. Within the timer behavior, change the speed attribute to 200.

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

  • Simple Gamer ArtsSimple Gamer Arts Posts: 276Member, PRO

    In the actor that is moving down:
    • Create a self integer attribute: self.velocityY
    • Create a self integer attribute: self.timerspeedchange and set it to 10
    • Create a self integer attribute: self.speedY and set it to -150

    Create RULE inside that same actor:
    When velocity Y is < 0 ,
    •Then put a timer behaviour inside that rule:
    ••every 1 second:
    put a "change attribute" behaviour in that "timer" behaviour:
    • self.timerspeedchange to self.timerspeedchange-1

    Create another RULE inside that same actor:
    When self.timerspeedchange = 0:
    put a "change attribute:"
    • self.speedY to - 200

    Of course, you must use the motion attribute: self.velocity to command the speed of the actor... this is why you must use -150.

  • jessica.michaeljessica.michael Posts: 19Member, PRO


    I tried doing that and it didn't work so I must've put in the code wrong

  • jessica.michaeljessica.michael Posts: 19Member, PRO

    Its okay now, I got the change of speed working thank you!!

  • tatiangtatiang Posts: 11,525Member, Sous Chef, PRO, Senior Sous-Chef

    Glad you got it working. Another way to think of this is to understand that the Move behavior constantly checks the speed value. So you can also do it this way:

    Move [direction: 270] [speed: game.speed]

    Timer
         After 10 seconds
              Change attribute game.speed to game.speed+50

    That way, if you have other changes you want to make to the speed, you only need a single Move behavior.

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

Sign In or Register to comment.