Swift 如何在 Spritkit 中创建动态位​​置

How to make dynamic positions in Spritkit in Swift

我只有一个场景有以下变量:

widthOfScene = self.size.width
heightOfScene = self.size.height
var constLabelPosition = CGPoint(x:witdhOfScene*0.6, y: heightOfScene*0.95)
var dynamLabelPosition = CGPoint(x: constLabelPosition.x * 0.1, y: constLabelPosition.y)

我希望我的 dynamLabel 始终是我的 constLabel 的 10%,即使我决定在几个月内更改 constLabelPosition。 我的代码不工作。 dynamLabel 总是在 constLabel 的中间...有没有办法实现这种动态标签位置?

抱歉,这似乎是对 dynamicLabelPosition 的 x 位置的简单计算错误。

你确定你不是这个意思:

var dynamLabelPosition = CGPoint(x: constLabelPosition.x + constLabelPosition.x * 0.1, y: constLabelPosition.y)