Tap a point of display and start a transition that goes to that point?

Is it possible? It’s one of my game’s idea. Can I have the code? [import]uid: 27760 topic_id: 35199 reply_id: 335199[/import]

Sure, here is the basic way. You’ll need to expand on this in functionality, but it gives you a start…

local myObject = display.newRect(0,0,80,80) ; myObject:setFillColor(150)  
myObject.x, myObject.y = 100,100  
  
local function clearTrans()  
 transition.cancel( myObject.trans ) ; myObject.trans = nil  
end  
  
local function moveThing( event )  
  
 local phase = event.phase  
 local eventX = event.x  
 local eventY = event.y  
  
 if ( "began" == phase ) then  
 if ( myObject.trans ) then clearTrans() end  
 myObject.trans = transition.to( myObject, { time=2000, x=eventX, y=eventY, onComplete=clearTrans } )  
 end  
  
end  
  
local stage = display.getCurrentStage()  
stage:addEventListener( "touch", moveThing )  

Best of luck,
Brent [import]uid: 200026 topic_id: 35199 reply_id: 139984[/import]

Thank you, it runs perfectly with my game! [import]uid: 27760 topic_id: 35199 reply_id: 140072[/import]

Sure, here is the basic way. You’ll need to expand on this in functionality, but it gives you a start…

local myObject = display.newRect(0,0,80,80) ; myObject:setFillColor(150)  
myObject.x, myObject.y = 100,100  
  
local function clearTrans()  
 transition.cancel( myObject.trans ) ; myObject.trans = nil  
end  
  
local function moveThing( event )  
  
 local phase = event.phase  
 local eventX = event.x  
 local eventY = event.y  
  
 if ( "began" == phase ) then  
 if ( myObject.trans ) then clearTrans() end  
 myObject.trans = transition.to( myObject, { time=2000, x=eventX, y=eventY, onComplete=clearTrans } )  
 end  
  
end  
  
local stage = display.getCurrentStage()  
stage:addEventListener( "touch", moveThing )  

Best of luck,
Brent [import]uid: 200026 topic_id: 35199 reply_id: 139984[/import]

Thank you, it runs perfectly with my game! [import]uid: 27760 topic_id: 35199 reply_id: 140072[/import]