简体   繁体   English

将多个对象移动固定距离

[英]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. 我已经使用display.newGroup()将所有分组,并将它们插入该组。 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 https://docs.coronalabs.com/api/library/transition/to.html#examples

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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