2016-05-12 81 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