绘制两个圆圈时,实时取景显示奇怪的图像
When drawing two circles live view shows strange image
我需要在 iPad 上的 Swift PlayGrounds 中画 2 个(1 个我有同样的问题)。但是当它是运行的时候我就很奇怪result
class GameScene: SKScene{
var player = SKShapeNode(circleOfRadius: 0.1)
var earth = SKShapeNode(circleOfRadius: 0.01)
override func didMove(to view: SKView){
//physicsWorld.gravity = CGVector(dx: 0, dy: -0.9)
player.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
player.physicsBody?.affectedByGravity = false
player.physicsBody?.isDynamic = false
player.physicsBody?.mass = 1
earth.position = CGPoint(x: self.frame.midX , y: player.position.y - 0.5)
earth.physicsBody = SKPhysicsBody(circleOfRadius: 20.0)
earth.physicsBody?.affectedByGravity = false
earth.physicsBody?.isDynamic = false
player.fillColor = #colorLiteral(red: 0.9254902005195618, green: 0.23529411852359772, blue: 0.10196078568696976, alpha: 1.0)
earth.fillColor = #colorLiteral(red: 0.34117648005485535, green: 0.6235294342041016, blue: 0.16862745583057404, alpha: 1.0)
addChild(earth)
addChild(player)
}
}
首先,它们非常小,也许仅仅因为这个原因你就看不到它们。
其次,我猜你还需要定义 lineWidth
和 strokeColor
。
我需要在 iPad 上的 Swift PlayGrounds 中画 2 个(1 个我有同样的问题)。但是当它是运行的时候我就很奇怪result
class GameScene: SKScene{
var player = SKShapeNode(circleOfRadius: 0.1)
var earth = SKShapeNode(circleOfRadius: 0.01)
override func didMove(to view: SKView){
//physicsWorld.gravity = CGVector(dx: 0, dy: -0.9)
player.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
player.physicsBody?.affectedByGravity = false
player.physicsBody?.isDynamic = false
player.physicsBody?.mass = 1
earth.position = CGPoint(x: self.frame.midX , y: player.position.y - 0.5)
earth.physicsBody = SKPhysicsBody(circleOfRadius: 20.0)
earth.physicsBody?.affectedByGravity = false
earth.physicsBody?.isDynamic = false
player.fillColor = #colorLiteral(red: 0.9254902005195618, green: 0.23529411852359772, blue: 0.10196078568696976, alpha: 1.0)
earth.fillColor = #colorLiteral(red: 0.34117648005485535, green: 0.6235294342041016, blue: 0.16862745583057404, alpha: 1.0)
addChild(earth)
addChild(player)
}
}
首先,它们非常小,也许仅仅因为这个原因你就看不到它们。
其次,我猜你还需要定义 lineWidth
和 strokeColor
。