1
我尝试在写在cocos2d上的应用程序中创建动画。我在本教程中使用它 http://getsetgames.com/tag/ccanimation/ 一切正常。但是我在Engine类中编写了所有代码。另外我也有课堂,我想要动画。我有创建对象的特殊类。现在cocos2d动画
我尝试它必须有动画spritesheet未来 文件。 // GiftSprite.h
#import <Foundation/Foundation.h>
#import "cocos2d.h"
#import "LevelScene.h";
@interface GiftSprite : CCSprite {
...
CCSpriteSheet *giftSpriteSheet;
}
...
@property (assign, readwrite) CCSpriteSheet *giftSpriteSheet;
...
@end
文件女巫创建GiftSprite和方法addGift
-(void) addGift: (ccTime) time {
gift.giftSpriteSheet = [CCSpriteSheet spriteSheetWithFile:@"redGift.png"];// In this place I try retain.
gift = [GiftSprite spriteWithTexture:gift.giftSpriteSheet.texture rect:CGRectMake(0,0,30,30)];
}
和文件,如果一些事件渔获物制作动画。
NSLog(@"%@", gift.giftSpriteSheet);// in this place I see NULL
CCAnimation *fallingShowAnimation = [CCAnimation animationWithName:@"fallingInSnow" delay:0.5f];
for(int x=0;x<6;x++){
CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:gift.giftSpriteSheet.texture rect:CGRectMake(x*30,0,30,30) offset:ccp(0,0)];
[fallingShowAnimation addFrame:frame];
}
CCAnimate *giftAnimate = [CCAnimate actionWithAnimation:fallingShowAnimation];
[gift runAction:giftAnimate];
当我做到了。在我的动画中,我只看到了白色方块。 我该如何解决这个问题