End Function 不被识别 - Lua

我现在有一个非常讨厌的错误,每当我运行这段代码时

function player.detect() 

  for j = #bullet, 1, -1 do
      if CheckCollision(bullet[j].x, bullet[j].y, bullet.w, bullet.h, enemy.x, enemy.y, enemy.w, enemy.h) then
        table.remove(bullet, j)
      end
    end 
  end

  for j = #enemy, 1, -1 do
      if CheckCollision(bullet.x, bullet.y, bullet.w, bullet.h, enemy[j].x, enemy[j].y, enemy.w, enemy.h) then
        table.remove(enemy, j)
      end
    end 
  end 
end

它说:错误:语法错误:player.lua:118:' '附近需要''。

是的,这是player.lua,而且显示的代码是第104-119行。谢谢阅读!任何帮助都有用!

点赞
用户3979429
用户3979429

你有太多的结尾!

function player.detect()
  for j = #bullet, 1, -1 do
      if CheckCollision(bullet[j].x, bullet[j].y, bullet.w, bullet.h, enemy.x, enemy.y, enemy.w, enemy.h) then
        table.remove(bullet, j)
    end
end

  for j = #enemy, 1, -1 do
      if CheckCollision(bullet.x, bullet.y, bullet.w, bullet.h, enemy[j].x, enemy[j].y, enemy.w, enemy.h) then
        table.remove(enemy, j)
      end
    end
end
2015-12-20 17:42:40