public override void update(float time) { List <CCSpriteFrame> pFrames = m_pAnimation.getFrames(); int numberOfFrames = pFrames.Count; int idx = (int)(time * numberOfFrames); if (idx >= numberOfFrames) { idx = numberOfFrames - 1; } CCSprite pSprite = (CCSprite)(m_pTarget); if (!pSprite.isFrameDisplayed(pFrames[idx])) { pSprite.DisplayFrame = pFrames[idx]; } }
public bool initWithAnimation(CCAnimation pAnimation, bool bRestoreOriginalFrame) { if (base.initWithDuration(pAnimation.getFrames().Count *pAnimation.getDelay())) { this.m_bRestoreOriginalFrame = bRestoreOriginalFrame; this.m_pAnimation = pAnimation; this.m_pOrigFrame = null; return(true); } return(false); }
// Animation /// <summary> /// changes the display frame with animation name and index. /// The animation name will be get from the CCAnimationCache /// @since v0.99.5 /// </summary> public void setDisplayFrameWithAnimationName(string animationName, int frameIndex) { Debug.Assert(animationName != null); CCAnimation a = CCAnimationCache.sharedAnimationCache().animationByName(animationName); Debug.Assert(a != null); CCSpriteFrame frame = a.getFrames()[frameIndex]; Debug.Assert(frame != null); DisplayFrame = frame; }
public bool initWithAnimation(CCAnimation pAnimation, bool bRestoreOriginalFrame) { Debug.Assert(pAnimation != null); if (base.initWithDuration(pAnimation.getFrames().Count * pAnimation.getDelay())) { m_bRestoreOriginalFrame = bRestoreOriginalFrame; m_pAnimation = pAnimation; m_pOrigFrame = null; return true; } return false; }
public bool initWithAnimation(CCAnimation pAnimation, bool bRestoreOriginalFrame) { Debug.Assert(pAnimation != null); if (base.initWithDuration(pAnimation.getFrames().Count *pAnimation.getDelay())) { m_bRestoreOriginalFrame = bRestoreOriginalFrame; m_pAnimation = pAnimation; m_pOrigFrame = null; return(true); } return(false); }