Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我收到一条错误消息:Attempt to perform arithmetic on field 'x'尝试重新加载之前加载的场景时。
Attempt to perform arithmetic on field 'x'
我发现由于以下行而发生错误:
bg1.x = bg1.x - scrollSpeed
我能做些什么来解决这个问题?
谢谢!
你得到的错误可能是这样的:
attempt to perform arithmetic on field 'x' (a nil value)
这意味着您没有bg1.x正确初始化。执行此操作,或使用如下默认值:
bg1.x
bg1.x = (bg1.x or 42) - scrollSpeed
我选择了42,但您可能想要0...
42
0