Jump to content

jump does not behave as I expect. need help!


fkkcloud
 Share

Recommended Posts

Hi,

I am using ARCADE physics for my phaser game and I am trying to make my character jump only when this guy is on the ground.

I have ground sprite does the collision and when the callback happens for ground, I get a variable called "onGround" to be true so whenever user push space bar it will jump but when its not onGround, I made the onGround to be false so it won't do the jump in the sky.

However, when it land on the ground, it almost feel like there is a delay of 8~10ms to be recorgnized as it collided with the ground? 

Did anybody had similar issue?

update function has below code for collision

 

this.onGround = false;

this.game.physics.arcade.collide(sprite, block, this.blockCollisionHandler, null, me);

and 

blockCollisionHandler: function(){
        this.onGround = true;
}

and

jump: function(){
    if(this.onGround) this.sprite.vel.y = 1000; // peuso
}

Hope that make sense.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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