Zarkor Posted July 3, 2015 Share Posted July 3, 2015 Hi guys, i'm quite new to phaser and i got a problem with player movements: when i run+jump and the player collide with a ledge it stop the player velocity making the sprite continue running but it stay on the same "game.x" even if it's not colliding more (it lands on the ground because of the gravity). It restart to move just when i release and i re-tap/click the movement arrows. I managed UI, player and environment with separated objects. the GUI object manage player movements as it throw onDown events on the interface. In the update function of the game state i just declared the player/platformGroup collision...Any tip? Part of the used code:BasicGame.Game.prototype = { create: function () { environment.addEnvironment(this.game); playerManager.addPlayer(this.game); gui.addControls(this.game);[...] update: function () { this.game.physics.arcade.collide(player, platforms);}[...]gui.addControls = function(game){ buttonleft = game.add.button(10, 413, 'movementButtons', null, this, 0, 1, 0, 1); buttonleft.fixedToCamera = true; buttonleft.events.onInputOver.add(gui.left); buttonleft.events.onInputOut.add(gui.resetPosition, {position:"left"}); buttonleft.events.onInputDown.add(gui.left); buttonleft.events.onInputUp.add(gui.resetPosition, {position:"left"});[...]gui.left = function(){ player.body.velocity.x = -player.champion.moveSpeed; player.aim = "left"; player.animations.play('runLeft');};[...]gui.resetPosition= function(){ player.body.velocity.x = 0; player.state = "stay"; if(this.position == "left"){ player.animations.play('idleLeft'); }else{ player.animations.play('idleRight'); }}; Link to comment Share on other sites More sharing options...
Skeptron Posted July 6, 2015 Share Posted July 6, 2015 I had the same problem. The workaround I used was to make an intermediate var. So when the user goes left, do player.VELOCITY_X = 4, and in every player.update() do player.velocity.x = player.VELOCITY_X. Don't forget, when the user releases the left button, to set player.VELOCITY_X to 0. Link to comment Share on other sites More sharing options...
Skeptron Posted July 6, 2015 Share Posted July 6, 2015 The link to my old post, if it helps : http://www.html5gamedevs.com/topic/8904-collisions-and-velocity/ Link to comment Share on other sites More sharing options...
Recommended Posts