<b> ∆∆ "Follow my finger" tutorial ∆∆ - Included project file </b>
LeonardDeveloper
Member Posts: 4,630
Hey All,
This is a very commonly asked question, "How do I get an actor to follow my touch"
Well I decided to post this thread so that people have something to refer to now and of course to make the most of this new tutorials section!, This is a clever little tutorial; not only will it follow your finger it will also move the actor to the point that you touch as well!
As Follows:
Here is the project file of this in action: http://thermo-apps.com/wp-content/uploads/2012/07/touchfollowerbythermoapps.zip
Tutorial Step-by-Step
1.Select an actor you would like to have this control over/Perform the action on
2. (Optional) Create walls so they actor doesn't go flying off the screen
3. Add two "Constrain Attribute" behaviors to the actor,
4. Then you want to have in the first box of the first "constrain attribute behavior" the text as follows " "self.motion.linear velocity.x" You can enter this by pressing the expression editor button and clicking "actorName"> "Motion">Linear velocity x
5. Then in the second box you want: "game.Touches.Touch 1.X - self.Position.X" You can find this by pressing the expression editor button and clicking "game>Touches>Touch 1.X>self.Position.X
6. Then repeat the same for the second behavior but this time using "self.motion.linear velocity.y" instead of "self.motion.linear velocity.y"
And a quick video of it in action:
Cheers,
J.Leonard
This is a very commonly asked question, "How do I get an actor to follow my touch"
Well I decided to post this thread so that people have something to refer to now and of course to make the most of this new tutorials section!, This is a clever little tutorial; not only will it follow your finger it will also move the actor to the point that you touch as well!
As Follows:
Here is the project file of this in action: http://thermo-apps.com/wp-content/uploads/2012/07/touchfollowerbythermoapps.zip
Tutorial Step-by-Step
1.Select an actor you would like to have this control over/Perform the action on
2. (Optional) Create walls so they actor doesn't go flying off the screen
3. Add two "Constrain Attribute" behaviors to the actor,
4. Then you want to have in the first box of the first "constrain attribute behavior" the text as follows " "self.motion.linear velocity.x" You can enter this by pressing the expression editor button and clicking "actorName"> "Motion">Linear velocity x
5. Then in the second box you want: "game.Touches.Touch 1.X - self.Position.X" You can find this by pressing the expression editor button and clicking "game>Touches>Touch 1.X>self.Position.X
6. Then repeat the same for the second behavior but this time using "self.motion.linear velocity.y" instead of "self.motion.linear velocity.y"
And a quick video of it in action:
Cheers,
J.Leonard
Comments
No problem, Glad it helped