Я пересмотрю свой ответ, если это не то, о чем вы просили, но я думаю, вы спрашиваете, как «вручную запускать анимацию» с помощью спрайта без plist. Вот один из способов. Было бы лучше, если бы вы инкапсулированные это в собственный класс, но это может подтолкнуть вас в правильном направлении, я думаю:
ManualAnimationTest.h
@interface ManualAnimationTest : CCLayer
{
CCSprite *animatedSprite;
int x,y;
float animatedSpriteWidth, animatedSpriteHeight;
int animatedSpriteColumns, animatedSpriteRows;
}
@end
ManualAnimationTest.m
#import "ManualAnimationTest.h"
@implementation ManualAnimationTest
-(id) init
{
if((self=[super init]))
{
CGSize s = [CCDirector sharedDirector].winSize;
x = 0;
y = 0;
animatedSpriteColumns = 3;
animatedSpriteRows = 2;
animatedSpriteWidth = 95.0f;
animatedSpriteHeight = 125.0f;
animatedSprite = [CCSprite spriteWithFile:@"animal_animation.png" rect:CGRectMake(x * animatedSpriteWidth,y * animatedSpriteHeight,animatedSpriteWidth,animatedSpriteHeight)];
[self addChild:animatedSprite];
[animatedSprite setPosition:ccp(s.width/2.0f, s.height/2.0f)];
[self schedule:@selector(animateAnimatedSprite) interval:0.5f];
}
return self;
}
-(void) animateAnimatedSprite
{
[animatedSprite setTextureRect:CGRectMake(x * animatedSpriteWidth, y * animatedSpriteHeight, animatedSpriteWidth, animatedSpriteHeight)];
x +=1;
if(x > (animatedSpriteColumns - 1))
{
x = 0;
y +=1;
}
if(y > (animatedSpriteRows - 1))
{
y = 0;
}
}
@end
Я думаю, непонятно, что вы спрашиваете. Вы спрашиваете, как сделать 6 отдельных .png для сохранения на диск из этого? Вы спрашиваете, как использовать png как есть, но как анимацию? – Mark