iphone - cocos2d CCScene 背景定向

标签 iphone objective-c ios cocos2d-iphone iphone-5

我正在尝试使用以下代码为我的场景添加背景图像:

    CCSprite* background = [CCSprite spriteWithFile:@"background-hd.png"];
    background.tag = 1;
    background.anchorPoint = CGPointMake(0,0);
    [self addChild:background];

我的应用程序方向是横向,图像的方向也是横向,但我得到的图像方向是纵向:

http://i.stack.imgur.com/ZIFnU.png

最佳答案

我认为这是使用 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/

相关文章:

iPhone-如何将 Storyboard 与自定义 UITableView 单元格和 CellWithIdentifier 一起使用

ios - 哪个委托(delegate)方法在单击时触发 CLLocationManager 不允许

ios - 在 Linux 中开发 iOS 应用程序的状态如何?

ios - 如何在 GMSMapView 上实现 GMSMarker 拖放?

iOS 8 键盘扩展按钮不显示

ios - 如何在隐藏或取消隐藏时为 UIView 设置动画

iphone - 如何在 iOS 7 中以编程方式隐藏状态栏?

ios - 在 IOS Objective c 应用程序中自定义导航栏

ios - 如何加载 6.0 之前的默认排行榜?

ios - 将历史数组值插入 UITableViewController