Object should only be allowed to move when object.x is withing 20 and 530 [having the object horizontal size: 90].
Horizontal room size: 640.
This doesn't seem to work...:
function Block_AnyClick()
{
Object* myobject = Object.GetAtScreenXY(mouse.x, mouse.y);
if ((myobject.X <=530 && myobject.ClickedRightHalf())) myobject.Move(myobject.X+100, myobject.Y, 10, eBlock, eAnywhere);
//move left
else if (myobject.X >=20) myobject.Move(myobject.X-100, myobject.Y, 100, eBlock, eAnywhere);
//move right
}
Your "else" runs even if only the <= part fails, so instead try:
function Block_AnyClick()
{
Object* myobject = Object.GetAtScreenXY(mouse.x, mouse.y);
if ((myobject.X <=530 && myobject.ClickedRightHalf())) myobject.Move(myobject.X+100, myobject.Y, 10, eBlock, eAnywhere);
//move left
else if (myobject.X >=20 && !myobject.ClickedRightHalf()) myobject.Move(myobject.X-100, myobject.Y, 100, eBlock, eAnywhere);
//move right
}
The object is still moving through its bounderies...
Edit: changed the <='number' and the >='number' , now it works.