2016-05-12 82 views
0

我正在使用SpriteKit开发通用游戏(iPhone和iPad),并且我有背景大小问题。 我为1136x852尺寸的iPhone设备创建了图像大小2048x1536以及更多图像,并且仍然在iPhone上裁剪背景。 我该如何解决它?通用应用背景SpriteKit

let screenHeight = screenSize.size.height 

    //Backgorund 

    var dayBackground = SKSpriteNode(imageNamed:"BackgroundDay") 
    dayBackground.zPosition = -1 
    dayBackground.position = CGPoint(x:size.width/2, y:size.height/2) 
    dayBackground.anchorPoint = CGPointMake(0.5, 0.5) 
    dayBackground.size = self.frame.size 

GameViewController:

 if let scene = GameScene(fileNamed:"GameScene") { 
     // Configure the view. 
     let skView = self.view as! SKView 

     skView.showsFPS = true 
     skView.showsNodeCount = true 

     /* Sprite Kit applies additional optimizations to improve rendering performance */ 
     skView.ignoresSiblingOrder = true 

     /* Set the scale mode to scale to fit the window */ 
     scene.scaleMode = .AspectFill 
     skView.presentScene(scene) 
    } 

iPhone 6加: The background is cropped

iPad的临: Fit to screen

iPhone 4S: Cropped background

资产文件: @1x size is 2048x1536 and @3x is 1136x852

@ 1X尺寸2048×1536是和@ 3X是1136x852 感规模.AspectFill.ResizeAll它不喜欢我想要什么SKSprtieNode的位置。 谢谢!

我试图将图片拆分为部分,但仍然被裁剪 我认为是因为iPhone 6 plus屏幕尺寸为736x414,场景尺寸为1024x768,如果我将场景更改为当前设备,我需要定位每个屏幕的精灵 enter image description here

+1

看看这个:http://www.paintcodeapp.com/news/ultimate-guide-to-iphone-resolutions – Whirlwind

+0

我看到所有的游戏使用相同的图像的所有大小我怎么能通过屏幕缩放尺寸? – user1569766

回答

0

设备的屏幕尺寸比率是不同的,并且您将不得不拉伸尺寸以适合屏幕,这可能看起来很奇怪。但是如果你确定你喜欢这个选项,你可以使用.Fill。最平滑的选择是继续使用.AspectFill并为每个屏幕维度创建一个图像。有创意!祝你好运!

+0

谢谢! SpriteKit很难:( – user1569766

+0

没问题!我开始用SpriteKit快速学习..过去几周我一直在尝试学习UIKit,现在很难。 –

+0

但是我怎样才能将SKSpriteNode放在所有设备上的相同位置? – user1569766