Hey guys, I am trying to create basic player movement and it is working! However, if you click the arrow key multiple times at once the player can go “inside” the wall. Then if you press it again, it move out. Any help would be greatly appreciated! Code below. Regards
Player Creation
player = display.newImage("images/player.png", 100, 100) physics.addBody(player, "dynamic", {friction=0, bounce=0.9 })
Wall Creation
function spawnWall(x,y) local wall= display.newImage("images/wall.png", x, y) physics.addBody(wall, "static",staticMaterial) end
Player Movement
function moveUp(event) if event.phase == "ended" then player.y = player.y - 100 end end function moveDown(event) if event.phase == "ended" then player.y = player.y + 100 end end function moveLeft(event) if event.phase == "ended" then player.x = player.x - 100 end end function moveRight(event) if event.phase == "ended" then player.x = player.x + 100 end end