【问题标题】:cocos2d CCScene background orientationcocos2d CCScene 背景定位
【发布时间】:2012-12-11 06:16:51
【问题描述】:

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

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

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

【问题讨论】:

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


    【解决方案1】:

    我认为这是使用图层设置场景的解决方案...

    +(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....

    希望对您有所帮助...

    【讨论】:

    • 行得通!但是问题是它自己的图像文件的方向,但无论如何谢谢!
    猜你喜欢
    • 1970-01-01
    • 2013-05-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多