-4

I made a function which made an SKLabelNode every time the mouse is clicked... now i want to refer to these nodes and change there position outside the function they were made in .. the update function how can i do that?

4

1 回答 1

0

您可以定义一个全局变量(如果您有更多精灵,则可以定义一个数组)

var label: SKLabelNode?

在您的创建方法中,您可以将新精灵分配给变量

func createLabel() {

  label = SKLabelNode()
  ...
}

现在您可以在更新方法中操作标签

func update() {
  label.DoSomething...
  ....
}
于 2014-11-23T21:01:52.887 回答