Lua blasterball-like app, offscreen problem.

i have just finished the first level of the app, and i have a problem with my paddle to return the ball. the paddle moves with my finger, on the x-axis, but does not stop at the screen’s edge. my code:

local paddle = display.newImageRect (paddle, {“paddle.png”, 120, 33})
paddle.x = 159
paddle.y = 275
function movePaddle( event )
paddle.x = event.x
paddle.y = 275
end
Runtime:addEventListener(“touch”, movePaddle)

the question is is there a way to limit the movement range to say 300 pixels, without messing up on bigger or smaller screens?

the paddle.png is just a paint png that is a 320x100 gray square. nothing advanced about it, just me being hopeful for a simple fix.
[import]uid: 68665 topic_id: 11176 reply_id: 311176[/import]

In your movePaddle function, perhaps wrap the code to move the paddle in an if then statement so it only is moveable to an X position on the left and X position on the right.

Something like…

function movePaddle( event ) if event.x \>= 50 and event.x \<= 300 then paddle.x = event.x paddle.y = 275 end end [import]uid: 7845 topic_id: 11176 reply_id: 40555[/import]

much appreciated. it worked well. [import]uid: 68665 topic_id: 11176 reply_id: 40709[/import]