当我更改SKScene的大小时,我的SKSpriteNode
会变形,如果我添加skScene!.scaleMode = .aspectFill
我的SKSpriteNode
退出屏幕
这是我的SKScene
BallNode.swift
class BallNode: SKSpriteNode {
required init?(coder aDecoder: NSCoder!) {
super.init(coder: aDecoder)
}
convenience public init() {
self.init(imageNamed:"ball.png")
let xPos = CGFloat(arc4random()%(canvasHeight))
let yPos = CGFloat(arc4random()%(canvasWidth))
self.position = CGPoint(x: xPos, y: yPos)
self.yScale = 0.10
self.xScale = 0.10
self.physicsBody = SKPhysicsBody(circleOfRadius: self.frame.size.width/2)
self.physicsBody!.friction = 0.0
self.physicsBody!.restitution = 1.0
self.physicsBody!.mass = 1.0
self.physicsBody!.linearDamping = 0.0
self.physicsBody!.allowsRotation = false
self.physicsBody!.affectedByGravity = true
self.physicsBody!.categoryBitMask = ballCategory;
self.physicsBody!.collisionBitMask = wallCategory;
self.physicsBody!.node?.name = "sheep"
}
override init(texture: SKTexture!, color: UIColor!, size: CGSize) {
super.init(texture: texture, color: color, size: size)
}
}