简体   繁体   中英

Moving multiple objects a fixed distance

I am currently making a game where I have several platforms flying around the screen. I have grouped all of them using the display.newGroup() and inserting them into that group. I would like to move these multiple platforms (which are all the same) a fixed distance at the same time. How would I do that?

I have tried using translation, but then, it seems that I can not move all of them a 'fixed' distance using it. Is there any other option?

Use transition instead of translation, here s an example

 local group = display.newGroup()
 group.x = value
 group.y = value 

 -- (1) move square to bottom right corner; subtract half side-length

 transition.to( group , { time=1500, alpha=0, x=(w-50), y=(h-50), onComplete=listener1 } )

For more details,

https://docs.coronalabs.com/api/library/transition/to.html#examples

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