0
我在iphone上的应用程序工作,我是新的cocos2d和目标c。 我有一些麻烦让精灵动画定位为我想要的。我有一个背景精灵,并有第二个动画精灵来覆盖它。在这种情况下,背景是一个人,动画精灵是眼睛闪烁。cocos2d ccsprite动画
CGSize winSize = [[CCDirector sharedDirector] winSize];
CCSprite * bg = [CCSprite spriteWithFile:@"victory.png"];
[bg setPosition:ccp(240, 160)];
[self addChild:bg z:0];
kidSheetBlinking = [CCSpriteSheet spriteSheetWithFile:@"victory_eyes.png"];
[self addChild:kidSheetBlinking z:0];
// create the sprite
kidSpriteBlinking = [CCSprite spriteWithTexture:kidSheetBlinking.texture rect:CGRectMake(0, 0, 80, 38)];
[kidSheetBlinking addChild:kidSpriteBlinking];
kidSpriteBlinking.position = ccp(winSize.width/2+15,winSize.height/2+62);
// create the animation
kidBlinking1 = [CCAnimation animationWithName:@"blinking1" delay:0.1f];
for (int x = 2; x > 0; x--) {
CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:kidSheetBlinking.texture rect:CGRectMake(x*80,0*38,80,38) offset:ccp(0,0)];
[kidBlinking1 addFrame:frame];
}
for (int x = 0; x < 3; x++) {
CCSpriteFrame *frame = [CCSpriteFrame frameWithTexture:kidSheetBlinking.texture rect:CGRectMake(x*80,0*38,80,38) offset:ccp(0,0)];
[kidBlinking1 addFrame:frame];
}
// create the action
kidBlinkingAction1 = [CCAnimate actionWithAnimation:kidBlinking1 ];
id play = [CCCallFunc actionWithTarget:self selector:@selector(onKidAnimEnd)];
// run the action
[kidSpriteBlinking runAction:[CCSequence actions:kidBlinkingAction1,play, nil]];
胜利的眼睛png是240x38所以有3帧是80x38似乎对我来说是正确的。但出于某种原因,我不能让动画与下面的图像正确对齐。精灵动画周围似乎也有一条细线。我已经尝试过多次移动精灵来排列它,所以它不能只是简单的重新定位它。我必须错过别的东西。任何想法都会很棒。这是我的第一个应用程序,所以假设我什么都不知道任何人都可以想到的任何东西,我可能漏掉了 感谢 摹