Jump to content

Function for single mouse click


ekeimaja
 Share

Recommended Posts

Now I managed to get moving with mouse working. Now I am creating jumping, which is made by pressing left mouse button.

 

How can I make my sprite to jump only ONCE, when left mouse button is clicked?

 

I explain this kind of procedure:

  1. When you press left button of your mouse ONCE. I mean once when you press left mouse button with your index finger and then release it. LIke you clicked the link of this thread.
     
  2. When you click, sprite jumps ONCE and then falls back to floor. Not jump twice, not begin to flow on air. Just jumps once.

 

Please, read this post once again before replying to this, so you fully understand my problem.

 

Because I have seen too many threads on these forums where have been asked help i.e. for p2 physics, and somebody has answered with arcade physics code.

Link to comment
Share on other sites

Well, just use the onInputUp event, or similar, because you can not trigger up without first clicking down. And to make sure you can't click again while you are in air just keep a flag with didJump or isInAir which you reset when your sprite reaches the floor again.

 

You can find more examples here: http://gamemechanicexplorer.com/#platformer-4

Link to comment
Share on other sites

I have already looked that tutorial, but it does not help because it is for arcade physics. I use p2 physics.

 

In my game, floor is NOT world bottom bound. Collision is made with polylines for layer. So it need collisioncheck between player and polylines. Does there exist that kind of feature? WIth collisiongroups any collision does not work.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...