添加到 sceneGroup - 尝试索引全局 'self'(零值)

Adding to sceneGroup - Attempt to index global 'self' (a nil value)

sceneGroup 的另一个问题。

local function addScore (event)
local sceneGroup = self.view -- where the error is

然后稍后:

sceneGroup:insert( scoreStars )

local sceneGroup = self.view under scene:create, under sceneLshow(event), local sceneGroup = self.view, scene:hide( event ) 和 lua 文件。

在像 scene:something 这样的函数中,您会得到隐藏参数 self,它引用 scene 本身。在那些情况下 scene == self。在这些功能之外,您需要使用 scene.view 假设存在 scene 对象。所以在 addScore 函数中使用 scene.view 而不是 self.view.

您可以在 Understanding the colon vs. dot operator or Introducing the Composer API 中找到更多信息。