protected ePlayDirection m_curPlayDirection; // 如果是 PingPang 播放的时候当前播放方向 public SpriteAni() { m_leftTime = 0; m_curFrame = 0; m_bLoop = false; m_bNeedReloadRes = false; m_playState = SpritePlayState.eNone; m_playEndEventDispatch = new AddOnceAndCallOnceEventDispatch(); m_bKeepLastFrame = false; m_loopType = eSpriteLoopType.eSequence; m_curPlayDirection = ePlayDirection.ePositive; }
protected ePlayDirection m_curPlayDirection; // 如果是 PingPang 播放的时候当前播放方向 public SpriteAni() { m_leftTime = 0; m_curFrame = 0; m_bLoop = false; m_bNeedReloadRes = false; m_playState = SpritePlayState.eNone; m_playEndEventDispatch = new AddOnceAndCallOnceEventDispatch(); m_bKeepLastFrame = false; m_loopType = eSpriteLoopType.eSequence; m_curPlayDirection = ePlayDirection.ePositive; }
public void onTick(float delta) { if (SpritePlayState.ePlaying == m_playState) { m_leftTime += delta; if (m_leftTime >= m_tableBody.m_invFrameRate) { if (eSpriteLoopType.eSequence == m_loopType) // 顺序播放 { ++m_curFrame; m_curFrame %= m_tableBody.m_frameCount; } else // pingpang 播放 { if (ePlayDirection.ePositive == m_curPlayDirection) { if (m_curFrame == m_tableBody.m_frameCount - 1) // 如果上一帧是最后一帧 { m_curPlayDirection = ePlayDirection.eNegative; --m_curFrame; if (m_curFrame < 0) // 如果就一帧 { m_curFrame = 0; m_curPlayDirection = ePlayDirection.ePositive; } } else { ++m_curFrame; } } else // 如果向反方向播放 { if (m_curFrame == 0) // 如果上一帧是第一帧 { m_curPlayDirection = ePlayDirection.ePositive; ++m_curFrame; if (m_curFrame == m_tableBody.m_frameCount) // 如果总共就一帧 { m_curFrame = 0; m_curPlayDirection = ePlayDirection.eNegative; } } else { --m_curFrame; } } } m_leftTime -= m_tableBody.m_invFrameRate; updateImage(); if (m_curFrame == m_tableBody.m_frameCount - 1) { if (!m_bLoop) { stop(); dispEndEvent(); // 只有被动停止才会发送播放结束事件,如果是主动停止的,不会发送播放结束事件 } } } } }
public void onTick(float delta) { if (SpritePlayState.ePlaying == m_playState) { m_leftTime += delta; if (m_leftTime >= m_tableBody.m_invFrameRate) { if (eSpriteLoopType.eSequence == m_loopType) // 顺序播放 { ++m_curFrame; m_curFrame %= m_tableBody.m_frameCount; } else // pingpang 播放 { if(ePlayDirection.ePositive == m_curPlayDirection) { if (m_curFrame == m_tableBody.m_frameCount - 1) // 如果上一帧是最后一帧 { m_curPlayDirection = ePlayDirection.eNegative; --m_curFrame; if(m_curFrame < 0) // 如果就一帧 { m_curFrame = 0; m_curPlayDirection = ePlayDirection.ePositive; } } else { ++m_curFrame; } } else // 如果向反方向播放 { if(m_curFrame == 0) // 如果上一帧是第一帧 { m_curPlayDirection = ePlayDirection.ePositive; ++m_curFrame; if(m_curFrame == m_tableBody.m_frameCount) // 如果总共就一帧 { m_curFrame = 0; m_curPlayDirection = ePlayDirection.eNegative; } } else { --m_curFrame; } } } m_leftTime -= m_tableBody.m_invFrameRate; updateImage(); if (m_curFrame == m_tableBody.m_frameCount - 1) { if (!m_bLoop) { stop(); dispEndEvent(); // 只有被动停止才会发送播放结束事件,如果是主动停止的,不会发送播放结束事件 } } } } }