i am using cocos2d box2d in xcode, and i have 2 simple related issues that i am not sure about them.
-first and easy, whats the best way to change a sprite angle according to touch? i know how to handle touches,lets say i have a cannon i need to change its angle ?
second, I have some meter, that i want it to be filled with red color as i move my finger on it, do i need animation of this thing, in its all stages ? i mean- do i have to have an image with 20% filled with red col开发者_如何学运维or, and 50% filled and 75% filled, etc ? or there is another simple way ?
thanks a lot .
For the canon angle use the x directional touch movement to change the angle.
Something like:
-(void)ccTouchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
angle += [touch locationInView:[touch view]].x] - [touch previousLocationInView:[touch view]].x
}
As for the meter, have 2 images say gray background and red. Have the grey background be the 100% width and have the red one on top with a higher z order and scale it with the scaleX property.
精彩评论