2014-06-17 3 views
1

Swift와 함께 SpriteKit Framework를 사용하여 화면에 노드를 배치하려고했지만 원점이 어디인지 찾을 수 없습니다. 나는 그것이 왼쪽 하단 모서리에 있다고 생각했지만 node3을 배치하면 거기 어딘가에있는 화면에서 벗어난 것처럼 보입니다. node1 만 화면에 나타나면 누군가가 무슨 일이 일어나고 있는지 설명 할 수 있습니까?SpriteKit 좌표계 원점

class GameScene: SKScene { 
    override func didMoveToView(view: SKView) { 

    let node = SKSpriteNode(color: UIColor.greenColor(), size: CGSize(width: 50, height: 50)) 
    node.position = CGPoint(x:CGRectGetMidX(self.frame), y: CGRectGetMidY(self.frame)) 
    self.addChild(node) 

    let node2 = SKSpriteNode(color: UIColor.orangeColor(), size: CGSize(width: 50, height: 50)) 
    node2.position = CGPoint(x: 200.0 , y: 200.0 as Double) 
    self.addChild(node2) 

    let node3 = SKSpriteNode(color: UIColor.redColor(), size: CGSize(width: 50, height: 50)) 
    node3.position = CGPoint(x: 0.0 , y: 0.0) 
    self.addChild(node3) 
} 

SpriteKit 템플릿은 다음 뷰 구성을 가지고 : @ LearnCoco2D하여 전망을 언급 장면의 크기가 일치하지 않습니다으로

 let skView = self.view as SKView 

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

enter image description here

+0

시도의 200.f 및 200.f 대신 200 –

+0

죄송 동료, 같은 결과 :/ –

+2

Origin은 왼쪽 아래에 있습니다. 다른 결과가 나오면 scene.size가 사용자의 뷰와 방향과 일치하는지 확인하고, aspect.scaleMode를 aspect에 맞추거나 fill을 resize로 설정해야하는지 확인하십시오. – LearnCocos2D

답변

2

. 문제를 해결하기 위해 나는 scene.scaleMode를 ResizeFill로 변경하고 장면이 아닌 뷰를 기준으로 모든 직사각형을 그렸습니다.

scene.scaleMode = .ResizeFill