Constrain actor size to drag gesture?
![jonnyDiamond](http://forums.gamesalad.com/applications/dashboard/design/images/defaulticon.png)
Hi,
I have a tricky function that I cant solve. Here goes...
I want to control the size of an actor by touching it and dragging towards its center. As you touch the edge of the actor and drag towards its center - it gets smaller. As you drag outwards, away from its center - it gets bigger.
Currently I am able to track the x and y of a touch when you touch the actor but I can't figure out how to constantly measure the distance of the touch to the actors center. Also, I am not sure how to measure the distance as the touch drags away from the actor, because the touch may drag outside of the actor which means I may lose the x and y of the touch.
Am I approaching this the right way?
Any help will be greatly appreciated. Thanks
I have a tricky function that I cant solve. Here goes...
I want to control the size of an actor by touching it and dragging towards its center. As you touch the edge of the actor and drag towards its center - it gets smaller. As you drag outwards, away from its center - it gets bigger.
Currently I am able to track the x and y of a touch when you touch the actor but I can't figure out how to constantly measure the distance of the touch to the actors center. Also, I am not sure how to measure the distance as the touch drags away from the actor, because the touch may drag outside of the actor which means I may lose the x and y of the touch.
Am I approaching this the right way?
Any help will be greatly appreciated. Thanks
Comments
Its in the expression editor under functions
you'll create a real self attribute on the ball called distancetoCenter
then a rule
when touch is inside
--Constrain attribuite self.distancetocenter to magnitude(self.position.x-game.mouseposition.x,self.position.y-game.mouseposition.y)
--Constrain attribute self.width to self.distancetocenter*2
Hope that helps you out.
___________________________________________________________________________________
GS BubbleBall Template HERE!!
Stacks Level Selection Template HERE!!
Expanding Option Menu Template HERE!!
Tenrdrmer's Menu # 3 HERE!!
AppSolute Entertainment on Facebook
AppSolute Entertainment on iTunes
That worked a treat!
___________________________________________________________________________________
GS BubbleBall Template HERE!!
Stacks Level Selection Template HERE!!
Expanding Option Menu Template HERE!!
Tenrdrmer's Menu # 3 HERE!!
AppSolute Entertainment on Facebook
AppSolute Entertainment on iTunes