The laziest way to do so would be a tween for every new point of touch with a small duration for the tween. However if you need to rotate it, etc, then you have a bit more work cut out.
Just create a table of 10 or 20 slots, initially fill each one with the starting mouse position, then each time you get a mouse move event, move all the elements in the list down by 1 and put the new position in the top slot, then just set your object position to the last element.
The longer the table, the greater the distance the object will lag but it will always eventually end up in the right position.
local posTable
local cx,cy -- current (intial) mouse value-- setup
posTable={}for i=1,20do
posTable[i]={cx,cy}end-- each timefor i=20,2,-1do
posTable[i]= posTable[i-1]end
posTable[1]={cx,cy}
object:setPosition(posTable[20])
or something like that. You can use atan2() to get the angle to the mouse if you need to.
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Just create a table of 10 or 20 slots, initially fill each one with the starting mouse position, then each time you get a mouse move event, move all the elements in the list down by 1 and put the new position in the top slot, then just set your object position to the last element. @OZApps - even lazier!
@techdojo, what are you writing a Gideros version of the old retro Snake?
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Thank you @Scouser for neatly jumping hook line and sinker on that little bit of bait I left for you.
You never fail to bite
WhiteTree Games - Home, home on the web, where the bits and bytes they do play! #MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Comments
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
The longer the table, the greater the distance the object will lag but it will always eventually end up in the right position.
You can use atan2() to get the angle to the mouse if you need to.
@OZApps - even lazier!
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Likes: plamen
Likes: ar2rsawseen
http://www.giderosmobile.com/forum/discussion/2122/make-a-character-move-to-a-mouse-or-touch-then-stop#Item_1
Author of Learn Lua for iOS Game Development from Apress ( http://www.apress.com/9781430246626 )
Cool Vizify Profile at https://www.vizify.com/oz-apps
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill
Likes: OZApps
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
You never fail to bite
#MakeABetterGame! "Never give up, Never NEVER give up!" - Winston Churchill