Elasticity DEMO and Limiting Movement
I'm hoping someone is familiar with this demo if not I will post a link below. My question is... Using this demo how would one limit the range of movement that you can drag the actor. In the demo the actor is limited by he screen size, I would like to limit the actor to about 200 to 300 box of movement around the center. Any help would be awesome! and always appreciated...
Thanks guys!
Rob
Here is the demo link...
http://www.mediafire.com/?bco8owxf78z6mb8
Thanks guys!
Rob
Here is the demo link...
http://www.mediafire.com/?bco8owxf78z6mb8
Best Answer
-
JohnPapiomitis Posts: 6,256
in the ball actor youll see a rule when self.dragging it true
-constrain self position x to mouse position x
-constrain self position y to mouse position y
Change the constrains so there like so
-constrain self position x to max(140,min(340,mouse position x ))
-constrain self position y to max(60,min(260,mouse position y ))
You can adjust the min and max numbers to change the drag limit. Also thats based of screen position. The x position of the target actor is 240. So minus 100 is 140 and plus a hundred is 340. Thats how i got those numbers, so if you move the target actor just get its position and change the values accordingly with the range you want.
cheers
Answers