[SOLVED] How do I create one time animations?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Macsek
Prole
Posts: 11
Joined: Sat May 07, 2016 3:25 pm

[SOLVED] How do I create one time animations?

Post by Macsek »

I'm trying to use sodapop but I just can't figure it out..

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

It works for the first time and crashes after it with the message

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'

EDIT
Problem solved, library author helped me out.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 166 guests