Push a button to jump higher and higher

MLCinemaMLCinema Member Posts: 133
edited November -1 in Working with GS (Mac)
Hello All,

I am trying to make a button make an actor jump higher and higher. This is in portrait mode. If the button is not pushed the actor falls out of the screen.

I can't get anything to work. Any help would be appreciated.

Thank you

Comments

  • HachikoHachiko Member Posts: 330
    Do you mean like in mario platforms, where the more you left your finger on the button, the more the player will jump higher? My canabalt like template does just that :)
    Basically, you can have the accellerate down behaviour to simulate gravity to not fire when jump is true and mouse is down. When mouse is down and jump is true, change the motion linear Y to a given value. when the player reaches the highest point in his jump, or the finger is left from the screen, jump is false, and so gravity would start to kick in again. This is to avoid the use of constrain behaviour.
  • MLCinemaMLCinema Member Posts: 133
    WOW! I have no idea what you just said. :)

    I am still learning, but I do have your template which is GREAT. I will have to take a look at this. Maybe I can figure something out.

    Thank you.
  • HachikoHachiko Member Posts: 330
    Wait, I explain it a little better! :D Sorry but english is really not my language so I can get pretty confused at times :P
    You have an actor, which you want to be affected by gravity. Instead of using gs gravity, you put an accelerate behaviour towards down related to scene. Now player is affected by gravity. Now, you've got a boolean who you use to check if the player can jump. This variable will be false both when motion linear Y is < 0 (meaning, it is goind down and has no ground under its feet), both if mouse was down and is then released.
    You set it up like this
    if canJump is true and mouse is down then
    change attribute motion linear Y of player to a given value, the greater, the faster the jump and the higher the minimum jump.
    otherwise
    change attribute jump to false
    accelerate towards down related to scene

    what it lacks, is the ability to check the max higher possible jump. This can be done both with time, both with position. Basically, with position, in a variable you set the max pixel the player can flew over in it's Y axes. For example a jump of max 90 pixel. Now, you have another variable, called newMaxJump. When you touch the screen, you set that variable to position.Y + maxJump. And you get the new max possible point of the jump. Now, if while mouse is down, position.Y is >= of newMaxJump, then set canJump to false.
    And that's it :)
Sign In or Register to comment.