2016-08-12 11 views
1

私はプロジェクトで作業していますが、SKNodeはデバイスサイズに基づいて動的にサイズ変更されていません。SpriteKitは、画像が画面に合っていて、伸びていません。

例:

Image one enter image description here

私は2番目に発生する最初の画像の上に何が起こるかをしたいと思います。 これを自動的に行うには何かありますか?示された画像のための

現在のサイズ:

background.position = CGPoint(x: frame.size.width/2, y: frame.size.height/2) 
    background.size = CGSize(width: background.size.width/5.5, height: background.size.height/5.5) 

GameViewController:

import UIKit 
import SpriteKit 

class GameViewController: UIViewController { 

override func viewDidLoad() { 
    super.viewDidLoad() 

    // Configure the view. 
    let skView = self.view as! SKView 
    skView.showsFPS = false 
    skView.showsNodeCount = false 

    let scene = GameScene(size: skView.bounds.size) 

    scene.controller = self 
    scene.size = skView.bounds.size 

    /* 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) 
} 

override func shouldAutorotate() -> Bool { 
    return true 
} 

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { 
    if UIDevice.currentDevice().userInterfaceIdiom == .Phone { 
     return .AllButUpsideDown 
    } else { 
     return .All 
    } 
} 

override func didReceiveMemoryWarning() { 
    super.didReceiveMemoryWarning() 
    // Release any cached data, images, etc that aren't in use. 
} 

override func prefersStatusBarHidden() -> Bool { 
    return true 
} 
} 

答えて

0

あなたはこのゲームはあなただけ開く必要がある大画面で、デバイス上で提示されたとき、あなたのシーン全体のサイズを変更したい場合GameViewController.swiftをご確認の上、AspectFill

scene.scaleMode = .AspectFill 
+0

私はすでに私のGameViewController ..このコード行を持っています。多分それは無視されていますか? @appzYourLife –

関連する問題