我需要在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)
}
}
答案 0 :(得分:0)
首先,它们很小,也许您不能仅仅因为这个原因而看不到它们。
其次,我想您也需要定义lineWidth
和strokeColor
。