Federayk

Problem with the Jump of player

Recommended Posts

Hi guys! I'm new on Phaser (I use 2 version). I was create a placeholder and when I set movement of the player, specifically in the jump, doesn't work. Everything works but expect the jump. I let one fragment of the code and also the file. I couldn't find solution for now. I will be grateful with any help. Thank you! :)

update:function(){
    
        //COLLISION PLAYER AND TILESLAYER
    game.physics.arcade.collide(this.player, this.layer);
        
    
    
    //MOVEMENT OF PLAYER   
    this.player.body.velocity.x = 0;
       
    
        if (this.cursors.left.isDown) 
        {
        this.player.body.velocity.x -= 300
            
            this.player.animations.play('walking.l');
        
         }
        
        else if (this.cursors.right.isDown) 
        {
        this.player.body.velocity.x += 300;
        
            this.player.animations.play('walking.r')
        }
        
        else {
                //PLAYER DON'T MOVE
        this.player.body.velocity.x = 0
            this.player.frame = 0;
            this.player.animations.stop();
}
        
        
       //JUMP
        if (this.cursors.up.isDown && this.player.body.touching.down) {
           
        this.player.body.velocity.y -= 120;

            
         }
        

liquidadores.rar

Share this post


Link to post
Share on other sites

Hi! I tried that but it still doesn't work 😕
When I turned -= 300 to = -300 in this.player.body.velocity.x as well as in this.player.body.velocity.y But nothing has been changed.

The player don't jump when is touching the ground as well as when is not touching the ground. In both cases nothing happens.

 

Share this post


Link to post
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...

  • Recently Browsing   0 members

    No registered users viewing this page.