Back to project page FlashAndroid.
The source code is released under:
GNU General Public License
If you think the Android project FlashAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package flash.android.game; //from w w w . j a v a 2 s.c o m import java.io.IOException; import android.content.Context; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import flash.android.display.DisplayUtil; public class AnimClip { /** ??????? **/ private long m_lastPlayTime = 0; /** ???????ID **/ private int m_currentFrame = 0; /** ??frame??? **/ private int m_totalFrames = 0; /** ??????????? **/ private Bitmap[] m_bitmaps = null; /** ???????? **/ private boolean m_bLoop = false; /** ?????? **/ private boolean m_bEnd = false; private int m_delay; public void initAnimation(Context p_context, String p_assetsPath, int p_delay, boolean p_isLoop) throws IOException { this.m_bEnd = false; this.m_currentFrame = 0; this.m_delay = p_delay; this.m_bitmaps = DisplayUtil.getBitmapsFromAssets(p_context, p_assetsPath); this.m_bLoop = p_isLoop; this.m_totalFrames = m_bitmaps.length; } public void drawAnimation(Canvas p_canvas, int p_x, int p_y, Paint p_paint) { if (!m_bEnd) { p_canvas.drawBitmap(m_bitmaps[m_currentFrame], p_x, p_y, p_paint); long time = System.currentTimeMillis(); if (time - m_lastPlayTime > m_delay) { this.m_currentFrame++; if (m_currentFrame >= m_totalFrames) { if (m_bLoop) { m_currentFrame = 0; } else { this.m_bEnd = true; } } } } } }