Right now, the paddle does not move at all. There are no coordinates set that will allow the paddle to move side to side on the screen. So let's create them by performing the following steps:
Underneath the
addGameScreen()
function, create a new function calleddragPaddle(event)
:function dragPaddle(event)
Next, we'll focus on moving the paddle side to side within the boundary of the game screen. Add in the following block of code to enable paddle movement in the simulator and then close the function. The reason for adding this block is because the simulator does not support accelerometer events:
if isSimulator then if event.phase == "began" then moveX = event.x - paddle.x elseif event.phase == "moved" then paddle.x = event.x - moveX end if((paddle.x - paddle.width * 0.5) < 0) then paddle.x = paddle.width * 0.5 elseif((paddle.x + paddle.width * 0.5) > display.contentWidth) then paddle...