Hello guys, I am starting a new game, a work in progress. I am trying to make a player that always moves. It starts moving right continuously and if you press the left button it switches to going to the left continuously. And then you can press the right key to make it go to the right continuously.
However if you press either arrow key multiple times it “boosts” the player, making it go extra fast. Then when you press the other arrow you don’t move the other way, instead you just stop moving or in more drastic cases, continue to move in the SAME direction.
Here is my code.
player = display.newCircle(550,600,50) player:setFillColor(10,90,230) physics.addBody( player, { density = 1.0, friction = 0, bounce = 0, radius = 50 } ) local function goLeft (event) player:applyForce( -500, 0, player.x, player.y ) end local function goRight(event) player:applyForce( 500, 0, player.x, player.y ) end left:addEventListener("touch",goLeft) right:addEventListener("touch",goRight) goRight()
All help is appreciated.
Regards Summit Tech