Jump to content

Can't jump


hotgeart
 Share

Recommended Posts

Hi,

Sorry for my bad english.

I'm new in the world of html5 game and I'm trying to follow the tutorial from the book. I've an issue, I can't jump. I've no idea why.

A link for testing : http://not more online

If you look at the console, it's detecting the key up and if the player is touching the floor. But not the "JUMP!" and the velocity Y of course.

The code ( from : http://not more online ) :

Line 57if (this.cursor.up.isDown && this.player.body.touching.down) {    console.log('JUMP!');    this.player.body.velocity.y = -320;}

Thanks for your help.

Link to comment
Share on other sites

Ok it's work. Can you explain the problem ?

 

thx

You were checking this.player.body.touching.down before you called the Arcade Physics collide() method, thus it was always false when you checked it in your jumping code. Until you call collide() the Player object's body is not tested for touching anything...
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...