SKSpriteNode不会遵循确切的路径

问题描述 投票:0回答:1

问题在图像中描述。

到2:如果删除了阻塞节点,SKSpriteNode应该再次移动

enter image description here

sprite-kit skspritenode skaction
1个回答
1
投票

根据您在评论中的目标:

如果您需要将节点(SKSpriteNodeSKShapeNode等)移动到场景中的特定坐标,以下是您的示例:

let boxSize = CGSize(width: 50, height: 50)
var box = SKShapeNode(rect: CGRect(x: 25, y: 25, width: boxSize.width, height: boxSize.height))
var point = CGPoint(x: 25, y: 125)
var animTime:TimeInterval = 2
box.physicsBody = SKPhysicsBody.init(rectangleOf: boxSize)

let moveToPointAction = SKAction.move(to: point, duration: animTime)
box.run(moveToPointAction)
© www.soinside.com 2019 - 2024. All rights reserved.