I am new to cocos2D can anyone suggest an easy solution to the problem?
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.
EDIT
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];
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.
To make a CCSprite to rotate forever you could use something like
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.
EDIT 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.