Drawable Animation 帧动画_html/css_WEB-ITnose
程序员文章站
2022-03-28 09:12:18
...
MySurfaceView类:
package com.fm;import android.content.Context;import android.graphics.Bitmap;import android.graphics.BitmapFactory;import android.graphics.Canvas;import android.graphics.Color;import android.graphics.Paint;import android.util.Log;import android.view.KeyEvent;import android.view.MotionEvent;import android.view.SurfaceHolder;import android.view.SurfaceView;import android.view.SurfaceHolder.Callback;public class MySurfaceView extends SurfaceView implements Callback, Runnable { private SurfaceHolder sfh; private Paint paint; private Thread th; private boolean flag; private Canvas canvas; private int screenW, screenH; //首先声明十个容量的位图数组 private Bitmap fishBmp[] = new Bitmap[10]; //记录当前播放帧 private int currentFrame; // /** * SurfaceView初始化函数 */ public MySurfaceView(Context context) { super(context); sfh = this.getHolder(); sfh.addCallback(this); paint = new Paint(); paint.setColor(Color.WHITE); paint.setAntiAlias(true); setFocusable(true); //将每张小鱼帧图生成位图存入小鱼帧数组中 for (int i = 0; i = fishBmp.length) { currentFrame = 0; } } @Override public void run() { while (flag) { long start = System.currentTimeMillis(); myDraw(); logic(); long end = System.currentTimeMillis(); try { if (end - startMainActivity类:
package com.fm;import android.app.Activity;import android.os.Bundle;import android.view.Window;import android.view.WindowManager;public class MainActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //设置全屏 this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); requestWindowFeature(Window.FEATURE_NO_TITLE); //显示自定义的SurfaceView视图 setContentView(new MySurfaceView(this)); }}
推荐阅读
-
利用css3-animation实现逐帧动画效果
-
用animation的steps属性制作帧动画
-
CSS3 animation实现逐帧动画效果
-
HTML+css animation动画效果——做一个五角星轨迹运动
-
安卓开发之Animation学习(帧、补间、属性动画)
-
CSS中使用animation-timing-function:steps(num,start/end)实现逐帧动画
-
一款简洁的纯css3代码实现的动画导航_html/css_WEB-ITnose
-
一款纯css3实现的机器人看书动画效果_html/css_WEB-ITnose
-
css3 animation 学习_html/css_WEB-ITnose
-
8套迷人精致的CSS3 3D按钮动画_html/css_WEB-ITnose