我通過足球的約10個不同的圖像,以使它看起來就像是旋轉運行,但我是一個CCAnimation像這樣做(cocos2d的):CCAnimation
// load the football's animation frames as textures and create a sprite frame
frames = [[NSMutableArray alloc]initWithCapacity:3];
for (int i = 0; i < 10; i++)
{
NSString* file = [NSString stringWithFormat:@"Football%i.png", i];
CCTexture2D* texture = [[CCTextureCache sharedTextureCache] addImage:file];
CGSize texSize = texture.contentSize;
CGRect texRect = CGRectMake(0, 0, texSize.width, texSize.height);
CCSpriteFrame* frame = [CCSpriteFrame frameWithTexture:texture rect:texRect];
[frames addObject:frame];
}
CCAnimation* anim = [CCAnimation animationWithFrames:frames delay:0.03f];
// run the animation by using the CCAnimate action
CCAnimate* animate = [CCAnimate actionWithAnimation:anim];
CCRepeatForever* repeat = [CCRepeatForever actionWithAction:animate];
[self runAction:repeat];
所以我的問題當我與另一個物體相撞時,是否有辦法讓足球停止旋轉?
我確實使用了CCSpriteFrameCache:NSString * bulletFrame = [NSString stringWithFormat:@「Football-%i.png」,i]; CCSpriteFrame * frame = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:bulletFrame]; [frames addObject:frame]; – mm24 2012-05-17 17:10:13