Reputation: 1059
am trying to jump the different sprite at randomly .
am having 5 disffrent sprites have to display randomly . one sprite to be displayed
am tryed below code but its crashed :- warning: 'CCSprite' may not respond to '+spriteWithName:'
NSString *Sprit;
NSInteger rnd = arc4random() % 6;
if (rnd == 1) {
Sprit = @"Target.png";
} else if (rnd == 2) {
Sprit = @"3.png";
}else if (rnd == 3) {
Sprit = @"5.png";
} else if (rnd == 4) {
Sprit = @"8.png";
} else if (rnd == 5) {
Sprit = @"10.png";
} else {
Sprit = @"13.png";
}
CCSprite *target = [CCSprite spriteWithName:Sprit];
target.position = ccp(winSize.height + (target.contentSize.height/4), actualX);
[self addChild:target ];
Upvotes: 1
Views: 736
Reputation: 3448
Did you mean to use:
CCSprite *target = [CCSprite spriteWithFile:Sprit];
instead? Note that it's spriteWith*File*
There is some documentation for the CCSprite class here: http://www.cocos2d-x.org/embedded/cocos2d-x/d4/de7/classcocos2d_1_1_c_c_sprite.html
Upvotes: 3