【发布时间】:2020-07-25 07:54:11
【问题描述】:
这是一年前有效但现在由于某种原因无效的物理体代码。 这里我创建了物理体,但它实际上返回 nil。
SKPhysicsBody 中的每个元素:纹理和大小都不为零:
let playerPlaneTexture = atlas.textureNamed("airplane_3ver2_13")
print("###################")
print("playerPlaneTexture")
print(playerPlaneTexture)
let playerPlane = PlayerPlane(texture: playerPlaneTexture)
playerPlane.setScale(0.5)
playerPlane.position = point
playerPlane.zPosition = 40
print("###################")
print("playerPlane.size")
print(playerPlane.size)
playerPlane.physicsBody = SKPhysicsBody(texture: playerPlaneTexture, alphaThreshold: 0.5, size: playerPlane.size)
print("###################")
print("playerPlane.physicsBody")
print(playerPlane.physicsBody)
这是控制台输出,您可以在其中看到除了physicsBody之外的所有内容:
###################
playerPlaneTexture
'airplane_3ver2_13.png' (300 x 210)
###################
playerPlane.大小
(150.0, 105.0)
2020-07-25 12:48:36.428596+0500 WarFly[5557:400140] PhysicsBody:可以 不创建物理体。
###################
playerPlane.physicsBody
无
【问题讨论】:
标签: swift sprite-kit skphysicsbody