Created
December 23, 2012 18:16
-
-
Save aesmail/4365006 to your computer and use it in GitHub Desktop.
BackgroundLayer is not positioned in the center of the screen.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// BackgroundLayer | |
-(id) init { | |
self = [super init]; | |
if(self != nil) { | |
CCSprite *backgroundImage; | |
if(UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { | |
backgroundImage = [CCSprite spriteWithFile:@"background.png"]; | |
} else { | |
backgroundImage = [CCSprite spriteWithFile:@"backgroundiPhone.png"]; | |
} | |
CGSize screenSize = [[CCDirector sharedDirector] winSize]; | |
[backgroundImage setPosition:CGPointMake(screenSize.width/2, screenSize.height/2)]; | |
[self addChild:backgroundImage z:0 tag:0]; | |
} | |
return self; | |
} | |
// GameScene | |
-(id) init { | |
self = [super init]; | |
if(self != nil) { | |
BackgroundLayer *backgroundLayer = [BackgroundLayer node]; | |
[self addChild:backgroundLayer z:0]; | |
} | |
return self; | |
} | |
// app delegate | |
[director_ pushScene:[GameScene node]]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment