below is where the error may occur Here is my main.lua and I note the place where I think the error is. What I can't figure out is why this sentence will return a number value? I'm learning Downwell's effect and the tutorial link is here:https://github.com/a327ex/blog/issues/9
Object = require("classic")
GameObject = require("GameObject")
Timer = require 'hump/timer'
function love.load()
Game_objects = {}
Game_object = createGameObject('GameObject',100, 100)
--dealing with canvas
main_canvas = love.graphics.newCanvas(320, 240)
main_canvas:setFilter("nearest", "nearest")
love.window.setMode(960, 720)
timer = Timer()
--Here!
timer.after(4, function() Game_object.dead = true end)
end
function love.update(dt)
timer.update(dt)
for i = #Game_objects, 1, -1 do
Game_object = Game_objects[i]
Game_object:update(dt)
if Game_object.dead then
table.remove(Game_objects, i)
end
end
end
function love.mousepressed(x,y,button)
if button == 1 then
Game_object.dead =true
end
end
function love.draw()
love.graphics.setCanvas(main_canvas)
love.graphics.clear()
for _, Game_object in ipairs(Game_objects) do
Game_object:draw()
end
love.graphics.setCanvas()
love.graphics.draw(main_canvas, 0, 0, 0, 3, 3)
end
function createGameObject(type,x, y, opts)
local game_object = _G[type](x, y, opts)
table.insert(Game_objects, game_object)
return game_object -- return the instance in case we wanna do anything with it
end
just dont know and it had took me 2 days. can anyone help me~ :(