all
I am facing one problem the problem is that I want to hit an object infinite time and it show me the animation only once.. how can I do it.. plz give me an idea of this
code
ccTouches Function
if(firstValue >= 125 && sencndvalu <=138)
{
if(multipleTouch == 0)
{
[self FaceAni:@"chammat.plist"];
}
multipleTouch ++;
if(multipleTouch > 2)
[self fallingAnimation:@"fallingNew.plist"];
}
}
-(void)FaceAni:(NSString *)plistFile
{
multipleTouch = 0;
animationIsOn = 1;
[self removebackgroundTexture];
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:plistFile];
NSString *changeFileName = [NSString stringWithFormat:@"%@", plistFile];
changeFileName = [changeFileName stringByReplacingOccurrencesOfString:@".plist" withString:@".png"];
spriteSheet = [CCSpriteBatchNode batchNodeWithFile:changeFileName];
[self addChild:spriteSheet];
// Load up the frames of our animation
walkAnimFrames = [NSMutableArray array];
for(int i = 1; i <= 20; ++i)
{
if(i <= 9)
{
[walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Chmaat_0000%d.png", i]]];
}
else
{
[walkAnimFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"Chmaat_000%d.png", i]]];
}
}
CCAnimation *walkAnim = [CCAnimation animationWithFrames:walkAnimFrames delay:0.10f];
// Create a sprite for our bear
CGSize winSize = [CCDirector sharedDirector].winSize;
self.bear = [CCSprite spriteWithSpriteFrameName:@"Chmaat_00000.png"];
_bear.position = ccp(winSize.width/2, 230);
self.walkAction = [CCRepeatForever actionWithAction:[CCAnimate actionWithAnimation:walkAnim restoreOriginalFrame:NO]];
//[_bear runAction:_walkAction];
[spriteSheet addChild:_bear];
[_bear runAction:_walkAction];
// [[SimpleAudioEngine sharedEngine]playEffect:@”slap3.wav”];
timer = [NSTimer scheduledTimerWithTimeInterval:2.0 target:self selector:@selector(removeFrame) userInfo:nil repeats:NO];
}
You could:
The first time the animation is shown the flag will be set to NO and the animation won’t run again.