我正在尝试使用以下代码为我的场景添加背景图像:
CCSprite* background = [CCSprite spriteWithFile:@"background-hd.png"];
background.tag = 1;
background.anchorPoint = CGPointMake(0,0);
[self addChild:background];
我的应用程序方向是横向,图像的方向也是横向,但我得到的图像方向是纵向:
最佳答案
我认为这是使用 Layer 来设置场景方向的解决方案...
+(CCScene *) scene
{
CCScene *scene = [CCScene node];
StartLayer *layer = [StartLayer node];
CCSprite *background = [CCSprite spriteWithFile:@"background-hd.png"];
background.anchorPoint = ccp(0,0);
[layer addChild:background z:-1];
[scene addChild: layer];
return scene;
}
请参阅此链接了解更多信息 Cocos2d-Scenes-and-Layers ....
希望这对您有帮助......
关于iphone - cocos2d CCScene 背景定向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14027883/