Search code examples
pluginsluaspritecoronasdkchain

Chaining sprite sequences in Corona SDK?


So, I was chaining some sprite sequences recently and it took me a long time, considering the actual simplicity of the chain. I noticed, that if one wanted to do some more complex chains, that it would be extremely frustrating and probably not worth the effort.

This is a very simplified case with a sequence changing method of a sprite object, due to multiple image sheets, which works properly. But as soon as you get more complex, you end up with really hard to read code :

        function fox:playSeq()
            pcall(function() self:removeEventListener("sprite", self.sequenceChanger) end)
            local counter = 0
            function self.sequenceChanger(event)
                if event.phase == "ended" then
                    counter = counter + 1
                    if counter == 3 then
                        counter = 0
                    end
                    self:setSequence("walking"..(counter + 1))
                    self:play()
                end
            end
            self:addEventListener("sprite", self.sequenceChanger)
            self:play()
        end

I was just wondering if anybody here is aware of a plugin (module), that made the process of making a little more complex sprite animations (chaining them) easier.

Thanks for your help!

Greetings, Nils


Solution

  • I did not use sprite animation so far but maybe this advises will be useful for you. Try