everytime I resume some scene, the main character keeps walking along, because I think it's remember the movement from before the scene was paused. I set the velocity.x and velocity.y to 0 before pause the scene. But doesn't works. Any idea? Thanks!
Here is my code:
function workPopUp (){
this.scene.pause();
this.scene.launch('popup');
this.work.destroy();
}
This is the normal behaivor of velocity:
if (this.cursorKeys.left.isDown)
{
this.kid.setVelocityX(-200);
this.kid.anims.play('left', true);
}
else if (this.cursorKeys.right.isDown)
{
this.kid.setVelocityX(200);
this.kid.anims.play('run', true);
}
else
{
this.kid.setVelocityX(0);
this.kid.anims.play('idle', true);
};
if (this.cursorKeys.up.isDown && this.kid.body.touching.down)
{
this.kid.setVelocityY(-480);
this.kid.anims.play('jump', true);
}
if(this.cursorKeys.up.isDown && this.cursorKeys.right.isDown){
this.kid.anims.play('jump', true);
}else if(this.cursorKeys.up.isDown && this.cursorKeys.left.isDown){
this.kid.anims.play('jump', true);
}