简体   繁体   中英

Is it possible to change the x and y coordinates in a transition.to in Corona SDK

I'm having a hard time figuring this out. I want to make an object, in my case a ball,

local ball = display.newCircle(25,25,25)
ball.x = 160
ball.y = -80

to move from its starting coordinates to another spot, but then, after the action is completed I want it to immediately appear in another spot lets say x=90 and y= 120 and transition to another place. How can I do this with lua? Thank you in advance.

I am not sure if I understood you correctly.

Code below move ball from starting coordinates to destination coordinates. After ball reach its destination spot the x and y coordinate of ball are changed to x=90 and y= 120 and the second transition is called.

local function listener(self)
   -- self== ball in this case
   self.x = 90
   self.y = 120
   transition.to(self, {time=yourTime, x=newDestX, y=newDestY})
end

transition.to(ball, {time=yourTime, x=destX, y=destY, onComplete=listener})

For more information about transitions in Corona SDK read this .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM