I’m making a 2D platformer (How do you make a Ball or Sprite 'jump'?)

Here is one way. Depending on your Canvas y , and screen resolution, this can happen slowly or fast as the Clock cycles the pixels.


, the ball jumps, reaches a y value at the top of the screen, then falls immediately. You can code it to do anything else you want:

  • it can increment x at the same time it moves upward if you code it to.
  • look for a collision with a sprite and then do something dramatic randomly or at once.
  • randomly jump to the max or an intermediate position of the y axis
  • make it jump 'faster' by increasing the pixel increment from 1 to 2 or 3 etc.
  • use accelerometer to change the trajectory of the jump on the fly (or just add a button to increase x each time it is pressed.
  • etc.