Cocos2d - 更改为背景图像
Coco2dx - Changing To Background Image
我需要别人的帮助。实际上我不知道要替换什么来获得自定义背景图像。我实在不行了
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super's" return value
if( (self=[super initWithColor:ccc4(219,31,94, 999)]) ) {
ws=[[CCDirector sharedDirector]winSize];
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"game" ofType:@"wav"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
player.numberOfLoops=-1;
[player play];
创建并添加 CCSprite
:
CCSprite *bg = [CCSprite spriteWithFile:@"bg.png"];
bg.tag = 1;
bg.anchorPoint = CGPointMake(0, 0);
[self addChild:bg];
我需要别人的帮助。实际上我不知道要替换什么来获得自定义背景图像。我实在不行了
-(id) init
{
// always call "super" init
// Apple recommends to re-assign "self" with the "super's" return value
if( (self=[super initWithColor:ccc4(219,31,94, 999)]) ) {
ws=[[CCDirector sharedDirector]winSize];
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource:@"game" ofType:@"wav"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
AVAudioPlayer *player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
player.numberOfLoops=-1;
[player play];
创建并添加 CCSprite
:
CCSprite *bg = [CCSprite spriteWithFile:@"bg.png"];
bg.tag = 1;
bg.anchorPoint = CGPointMake(0, 0);
[self addChild:bg];