Search code examples
luaspritesequencecoronasdkprepare

Issues between switching two sprites


I'm new to corona sdk and I'm developing a game. My game has big characters and big sprite sheets as well. when testing a game I found that not every time but sometimes when I switch between two sprites it stuck the character and some other conditions related to the character.

following is the code...

    if(isSwapping == false and canSwipeBln == true) then
        isSwapping = true;

        canDuckBln = false;
        canJumpBln = false;
        canSwipeBln = false;

        tempSwapBln = touchBln;
        touchBln = false;

        print("current frame     == " .. hero.currentFrame);
        print("current sequence  == " .. hero.sequence); 

        if(hero.sequence ~= "goodNinjaSwipe") then
            hero:prepare("goodNinjaSwipe");
        end
        hero:play();

        print("current frame     == " .. hero.currentFrame);
        print("current sequence  == " .. hero.sequence); 
   end

When I try to debug it, it shows the name of the switched(goodNinjaSwipe) sprite but the number of frames of the old sprite(goodNinjaWalk). Is this the technical issue? I don't understand

Thanks in advance...


Solution

  • You are very probably mixing he two sprite APIs...

    "prepare" was used in the old API, this API is now deprecated...

    the new API uses "setSequence".