You just need to clamp the Player's position to the Square's bounding box while dragging
Player Is dragging
Set X to clamp(Player.x, Square.BBoxLeft, Square.BBoxRight)
Set Y to clamp(Player.y, Square.BBoxTop, Square.BBoxBottom)
This will keep the Player's origin within the Square, so you might need to adjust the values to keep the entire image within the Square, e.g. add half the Player's image width to BBoxLeft and subtract it from BBoxRight.
Thank you very much, i did it.
Now when i drag the player out of the square, the player stays inside the square (that's good), but when i drag my finger or mouse further i can still hit other things..
The player stays in the square but it stil hits things out the square like if the player is out of it when i drag my finger further.
Sorry for bad english..
// What the player is doing is like everything is a kind of physics and the goal is to bounce other things away..