Lua - 零值

Lua - nil value

我从 Corona SDK 收到以下错误消息:尝试调用字段 "ImageSheet"(零值)堆栈回溯。有人可以指出错误吗?

   local ISPar = {
    width = 2541,
    height = 264,
    numFrames = 7
 }
local ImageSheet = graphics.ImageSheet("Apus.png, ISPar")

local ApusSequenceData = {
  {name = "fly", frames {1,2,3,4,5,6,7}, time = 800, loopCount = 0}
  }

local Apus = display.newSrpite(ImageSheet, ApusSequenceData)
Apus.x = display.contentWidth/2
Apus.y = display.contentHeight/2
Apus:play()

你把函数名弄错了,应该是graphics.newImageSheet。你在调用它时也放错了引号。然后你拼错了 newSprite

此代码应该有效:

local ISPar = {
    width = 2541,
    height = 264,
    numFrames = 7
}
local ImageSheet = graphics.newImageSheet("Apus.png", ISPar)

local ApusSequenceData = {{name = "fly", frames = {1,2,3,4,5,6,7}, time = 800, loopCount = 0}}

local Apus = display.newSprite(ImageSheet, ApusSequenceData)
Apus.x = display.contentWidth/2
Apus.y = display.contentHeight/2
Apus:play()