Here is my attempt:
Code: Select all
local explosions = {}
local explanim = {}
function explosions.new(x, y, s)
for i = 1, 7, 1 do
randX = love.math.random(30, 60) + x
randY = love.math.random(30, 60) + y
table.insert(explosions, {sprite = sodapop.newAnimatedSprite(randX, randY)})
end
for i = 1, 7, 1 do
table.insert(explanim, {anim = explosions[i].sprite:addAnimation('explosion', {image = love.graphics.newImage 'data/explosion1.png', frameWidth = 50, frameHeight = 50, stopAtEnd = true, frames = {{1, 1, 7, 1, .08}}})})
end
end
function explosions.update(dt)
for i, v in ipairs(explosions) do
if v.sprite ~= nil then
v.sprite:update(dt)
end
end
end
function explosions.draw(dt)
for i, v in ipairs(explosions) do
if v.sprite ~= nil then
v.sprite:draw(dt)
end
end
end
return explosions
Code: Select all
Error: libs/sodapop.lua:153: attempt to index field 'current' (a nil value)
stack traceback:
libs/sodapop.lua:153: in function 'draw'
explosion.lua:26: in function 'draw'
main.lua:109: in function 'draw'
[string "boot.lua"]:468: in function <[string "boot.lua"]:436>
[C]: in function 'xpcall'
Problem solved, library author helped me out.