該解決方案幫助我:
把你的代碼,調用/添加從viewDidLoad
現場viewWillLayoutSubviews
- (void)viewWillLayoutSubviews
{
[super viewWillLayoutSubviews];
// Configure the view.
SKView * skView = (SKView *)self.view;
skView.showsFPS = YES;
skView.showsNodeCount = YES;
// Create and configure the scene.
SKScene * scene = [MyScene sceneWithSize:CGSizeMake(skView.bounds.size.width*2,skView.bounds.size.height*2)];
scene.scaleMode = SKSceneScaleModeAspectFill;
// Present the scene.
[skView presentScene:scene];
}
據我所知,原因是skView.bounds
是不同的當視圖即將被佈置以及視圖被顯示時。一般來說,我發現height
和width
被切換。
,我發現這個解決方案在這裏: Background image size Sprite Kit Game
這是工作部分,因爲它實際上是伸展我的形象,不知道爲什麼它會做這個? – vzm
如果您的圖像被稱爲Spaceship.png,它會將圖像拉伸到視網膜顯示的兩倍。你需要一個名爲[email protected]的文件來顯示視網膜。這個文件不應該被拉伸。 – godel9
此外場景還有一個scaleMode屬性,用於定義場景的內容如何縮放。 – LearnCocos2D