У меня возникла проблема с методом runAction для CCAnimation. Если я запустил команду после создания CCAnimate в initWithBodyPartImage, она будет работать нормально, без ошибок. Но, если я вызову метод runAction с помощью функции ccTouchBegan, приложение выйдет из строя, и на консоль не будет напечатана ошибка. Так что очень сложно понять, почему приложение терпит крах, когда я вызываю метод runAction из другой функции. Если кто-нибудь может мне помочь, я бы это оценил?iPhone runAction не работает
-(id) initWithBodyPartImage
{
// Loading the Body Part sprite using a sprite frame name (eg the filename)
if ((self = [super initWithSpriteFrameName:@"align_01.png"]))
{
state = kBodyPartUnTouched;
// create an animation object from all the sprite animation frames
anim = [CCAnimation animationWithFrame:@"align_" frameCount:7 delay:0.08f];
// run the animation by using the CCAnimate action
animate = [CCAnimate actionWithAnimation:anim];
//CCRepeatForever* repeat = [CCRepeatForever actionWithAction:animate];
repeat = [CCRepeat actionWithAction:animate times:1];
[self runAction:repeat]; // this is will work fine
}
return self;
}
- (BOOL)ccTouchBegan:(UITouch *)touch withEvent:(UIEvent *)event
{
[self runAction:repeat]; // This is where the app crashes
state = kBodyPartTouched;
return YES;
}