Magali Posted May 19, 2020 Share Posted May 19, 2020 Hi everyone! Everytime I resume my main scene, the main character keeps walking along and I can't control it with the keyboard. I think it's because remember the movement from before the scene was paused. I've tried everything, I set the velocity.x and velocity.y to 0 before pause the scene, create a variable isPaused and adapt the logict to that, but nothing works :(. Any idea? Thanks! My code: function workPopUp () { if(this.kid.body.velocity.x === 0){ this.scene.pause() this.scene.launch('popup'); this.work.destroy(); this.physics.add.overlap(this.kid, this.diamondsPink, collectCeleste, null, this); } } and this is the update loop this.kid.body.velocity.x = 0 ``````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); } Link to comment Share on other sites More sharing options...
gn1 Posted November 13, 2020 Share Posted November 13, 2020 simply reset cursors after resume for (const cursor in this.cursors) { this.cursors[cursor].reset(); } Link to comment Share on other sites More sharing options...
Recommended Posts