Jump to content

Boost Velocity Phaser


Chokitu
 Share

Recommended Posts

Hey everyone, I am really new to Phaser so If i ask something really stupid, I am sorry in advance, lol. 

 

 

I created an item named Redea that will boost the player speed for 15 seconds and change his sprites for 15 seconds, after that everything goes back to normal (this item will be activated when the player collides)

 

I created the collision and everything but the speed is not changing and I can't seem to change the sprite, can anyone help me here??

 

That's what I got

 

P.S The variable playerVelocity is because I was told that it can mess up with the physics if we tween the velocity.

 

Btw, I need to make it only appear sometimes on the same spot, tho.

 

Can anyone help me with that?

redeaFun: function(){
        
        this.emitter.x = this.redea.position.x;
        this.emitter.y = this.redea.position.y;
        this.emitter.start(true,500,null,15);

        this.playerVelocity = {x:0, y:0};
        
        this.game.add.tween(this.playerVelocity)
         .to({y: 500,x:500}, 5,true);
    
    },

update: function() {

    this.player.body.velocity.x=this.playerVelocity.x;
    this.player.body.velocity.y=this.playerVelocity.y;

}

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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