Event Sprite

I have a this program, where do an animation when different frames.

local function secuencia1 (sec_puerta,num_frames)

  if sec_puerta[num_frames]==0 then

    return 0

  else

    instance1:setSequence(vector[sec_puerta[num_frames]])

    instance1:play()

  end

end

local function spriteListener1 (event)

  print (event.phase)

    if event.phase==“end” then

      frames1 = frames1 +1

      secuencia1 (datos_secuencia1,frames1)

    end  

end

instance1:addEventListener(“sprite”, spriteListener1)

The problem is that I want to change to the library “display” and not using “sprite” and not how to implement the method addEvenLister with “sprite” to see avent.phase

Hi @mperezsoriano,

The sprite event phases are detailed in this tutorial under “Sprite Event Listeners”, along with example code:

http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/#topic6

They include “began”, “ended”, “bounce”, “loop”, and “next”.

Hope this helps,

Brent

I appreciate your response, I had already read this article but it does not work the event “ended”, after some testing I saw the sprites still another phase which is “next” and “loop”, changing these lines leave here as if anyone cares if I work

local function mySpriteListener( event )

  if  event.phase == “loop”  then

    local thisSprite = event.target  --“event.target” references the sprite

    thisSprite:setSequence( “fastRun” )  --switch to “fastRun” sequence

    thisSprite:play()  --play the new sequence; it won’t play automatically!

  end

end

animation:addEventListener( “sprite”, mySpriteListener )

Hi @mperezsoriano,

The sprite event phases are detailed in this tutorial under “Sprite Event Listeners”, along with example code:

http://www.coronalabs.com/blog/2012/10/02/animated-sprites-and-methods/#topic6

They include “began”, “ended”, “bounce”, “loop”, and “next”.

Hope this helps,

Brent

I appreciate your response, I had already read this article but it does not work the event “ended”, after some testing I saw the sprites still another phase which is “next” and “loop”, changing these lines leave here as if anyone cares if I work

local function mySpriteListener( event )

  if  event.phase == “loop”  then

    local thisSprite = event.target  --“event.target” references the sprite

    thisSprite:setSequence( “fastRun” )  --switch to “fastRun” sequence

    thisSprite:play()  --play the new sequence; it won’t play automatically!

  end

end

animation:addEventListener( “sprite”, mySpriteListener )