spawning of sprites
Hello, I'm new to cocos2D.I'm implementing my first game.I created one sprite and it is running successfully.But when i tried to create the same sprite multiple times it failed.Can anyone tell me the code how to implement this.Thanks in advance.
This is my code for creating a single sprite:
-(void) create
{
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"texture6.plist"];
animFrames = [NSMutableArray array];
CCSpriteFrame *frame1 = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"new1.png"];
[animFrames addObject:frame1];
CCSpriteFrame *frame2 = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"new2.png"];
[animFrames addObject:frame2];
CCSpriteFrame *frame3 = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"new3.png"];
[animFrames addObject:frame3];
// CCSpriteFrame *frame4 = [[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:@"4.png"];
// [animFrames addObject:frame4];
CCAnimation *animation = [CCAnimation animationWithName:@"blink" delay:0.1f frames:animFrames];
//CCRepeat *repeat= [CCRepeat
sprite = [CCSprite spriteWithSpriteFrameName:@"new1.png"];
sprite.position=ccp(390,200);
//sprite.flipX = 180;
x1=0;
y1=480;
[self addChild:sprite];
id animate = [CCAnimate actionWithAnimation:animation restoreOriginalFrame:NO];
id repeat= [CCRepeatForever actionWithAction:animate];
[sprite runAction:repeat];
speed = -.1;
}
|