iOS7 SpriteKit如何在iPad上将场景旋转为横向



我正在看Ray Wenderleich的这个精灵工具包教程,并下载了教程附带的样例游戏。

如何使用景观坐标系加载场景并布置其节点

虽然这个演示看起来是横向运行的,但经过一些测试,我发现教程中的场景仍然认为它是1024像素高(而不是768像素):

    self.player = [SKSpriteNode spriteNodeWithImageNamed:@"player"];
    DLog(@"middle: x%.2f y: %.2f",self.player.size.width/2, self.frame.size.height/2 );
    //middle: x13.50 y: 512.00
    DLog(@"bottom: x%.2f y: %.2f",self.player.size.width/2, self.frame.size.height/4 );
   //bottom: x13.50 y: 256.00 
    //this makes the figure appear at the very bottom of the screen
    self.player.position = CGPointMake(self.player.size.width/2, self.frame.size.height/4);
    [self addChild:self.player];

本教程可能会有所帮助:

http://www.ymc.ch/en/ios-7-sprite-kit-setting-up-correct-scene-dimensions

标准模板使用了错误的方法来设置场景!

最新更新