That sets the mole at the far right edge, at a random spot along the y axis. Then, instead of actionMove using CCMoveTo, you can just use CCMoveBy, setting the position to ccp(-winSize.width, 0).
If this isn't what you're looking for, perhaps you should rethink how to ask your question.
发布评论
评论(2)
如果您想将鼹鼠精灵放置在右侧的随机点上,您应该能够这样做:
将鼹鼠设置在最右边缘,即沿 y 轴的随机点处。
然后,您可以使用 CCMoveBy,而不是使用 CCMoveTo 进行 actionMove,并将位置设置为 ccp(-winSize.width, 0)。
如果这不是您想要的,也许您应该重新考虑如何提出问题。
If you want to place your mole sprite in a random spot along the right side, you should be able to just do:
That sets the mole at the far right edge, at a random spot along the y axis.
Then, instead of actionMove using CCMoveTo, you can just use CCMoveBy, setting the position to ccp(-winSize.width, 0).
If this isn't what you're looking for, perhaps you should rethink how to ask your question.
请参阅本教程创建从随机点开始向目标移动的敌人。它就在页面下方一点点。
编辑:
要创建随机 Y 生成点,请执行以下操作:(假设您使用的是 cocos2d)
然后只需将“摩尔”的位置设置为该点。
See this tutorial on creating enemies that move toward a target starting from a random point. It's a little ways down the page.
EDIT:
To create a random Y spawn point, do the following: (Assuming that you're using cocos2d)
Then simply set the position of the "mole" to that point.