Cocos2D帮助:如何连续旋转精灵,在旋转精灵中生成子精灵 [英] Cocos2D help: How to rotate a sprite continuously and generate child sprites in the rotating sprite

查看:207
本文介绍了Cocos2D帮助:如何连续旋转精灵,在旋转精灵中生成子精灵的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的cocos2D,任何人都可以建议一个简单的解决方案的问题?

I am new to cocos2D can anyone suggest an easy solution to the problem?

我有一个风车,在风车上有8个酒吧,每个酒吧分开45度,其中一半的风车在屏幕上,一半在屏幕之外。我想旋转风车,让它旋转永远。还有我想在风车酒吧的尾部附加一个孩子,它将与风车一起旋转。非常感谢。

I have a windmill with 8 bars on the windmill with each bar separated by 45 degrees, where half of the windmill is on screen and half is outside the screen. I want to rotate the windmill and make it rotate forever. Also I want to attach a child at the end of the windmill bars and it will rotate along with the windmill. An easy solution would be appreciated.

编辑

风车用,我写了这段代码:

I was able to rotate the windmill with, I wrote this piece of code:

windmill = [CCSprite spriteWithFile:@"Chorki.png"];
windmill.position = CGPointMake(winSize.width*0.02f, winSize.height*0.56f);
windmill.scale = 0.55f;
[self addChild:windmill z:0];
CCRotateBy *rot = [CCRepeatForever actionWithAction:[CCRotateBy actionWithDuration:5 angle: 360]];
[windmill runAction:rot];

现在请帮助我如何在每个风车棒的末端添加子sprite,有8

Now please help me on how to add child sprite at the end of each windmill bars, there are 8 bars in total and each bar is separated by 45 degrees.

推荐答案

要使CCSprite永远旋转,你可以使用类似

To make a CCSprite to rotate forever you could use something like

[windmill runAction:[CCRepeatForever actionWithAction:[CCRotateBy actionWithDuration:5.0 angle:360]]];

然后添加任何CCSprite作为孩子,它也会旋转。

then add any CCSprite as a child it will rotate too. The position that you assign to a child is based on his parent, take that in account.

编辑1

好吧,如果你知道圆的半径,你可以做一些数学,并得到你想要的位置。但是,如果你不需要计算位置,只是尝试&错误得到你想要的。尝试与风车无旋转。

Well, if you know the radius of the circle you can make some maths and get the position that you want. But also, if you don't need to calculate the positions, just try & error to get what you want. Try with the windmill without rotation.

这篇关于Cocos2D帮助:如何连续旋转精灵,在旋转精灵中生成子精灵的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆