1

当我尝试解包此表以调用图像时,程序返回错误“解包的参数错误(表预期得到用户数据)”

textures = {love.graphics.newImage("image.png"),
      love.graphics.newImage("image.png"),
      love.graphics.newImage("image.png"),
      love.graphics.newImage("image.png"),
      }

这是我正在使用的表

  drawScreenLineTexture[x] = {unpack(textures[map[mapX][mapY]])}
if side == 1 then
  drawScreenLineTexture[x][1] = drawScreenLineTexture[x][1] / 2
  drawScreenLineTexture[x][2] = drawScreenLineTexture[x][2] / 2
  drawScreenLineTexture[x][3] = drawScreenLineTexture[x][3] / 2
end

这是我尝试拆开桌子的地方

4

1 回答 1

2

如果要解压表格纹理:

textures = {love.graphics.newImage("image.png"),
      love.graphics.newImage("image.png"),
      love.graphics.newImage("image.png"),
      love.graphics.newImage("image.png"),
      }

你必须写unpack(textures),显然不是表格,unpack(textures[map[mapX][mapY])而是它的子元素之一,它恰好是 userdata 类型。textures[map[mapX][mapY]textures

于 2017-01-10T18:14:07.570 回答