Jump to content

Problem with the Jump of player


Federayk
 Share

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

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

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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