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)ユーザーデータ型である可能性のあるそのサブ要素の1つであるため、unpack(textures[map[mapX][mapY])書く必要があります。textures[map[mapX][mapY]textures

于 2017-01-10T18:14:07.570 に答える