What I'm doing is the game Pong, at the ends put some walls so that my rackets do not leave the screen, but with the touch if they manage to leave, does not respect their solid state.
Okay cool, I can help. There will need to be an event that prevents the racket from going beyond a grid position,
create another event very similar to the one I helped you with earlier.
If the game board is 300px across and the racket is 20px with a point of origin in the center then 10px will your buffer zone, this is the excess of the racket that will go off screen. so 300 - 10 is 290 so that is how we will find the buffer for the right side of the screen. 0 + 10 is the left side buffer. This helps us make two events:
If touch is > 290 then racket.x = 290
if touch is < 10 then racket.x = 10