- 1、本文档共8页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
笑脸游戏View界面
package com.net.face;import java.util.Random;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.graphics.Rect;import android.view.MotionEvent;import android.view.Surface;import android.view.SurfaceHolder;import android.view.SurfaceView;public class FaceView extends SurfaceView implements SurfaceHolder.Callback {//final int GOODS_RICE=0,GOODS_COFFEE=1,GOODS_WATERMELON=2,GOODS_BOMB=3;final int FACE_STATE_SMILE=0,FACE_STATE_REFUSE=1;Bitmap mBitmapFaceSmile,mBitmapFaceRefuse,mBitmapFaceLose;Bitmap []mBitmapGoods = new Bitmap[4]; //index 0:绫抽僉锛?锛氬挅鍟仛紝2锛氳僞鑔滐紱3锛氱偢椌?SurfaceHolder mHolder;int mSw,mSh;int mBitSide;int mGrade;int mLife=3;int m_x1,m_x2,m_x3;int m_y;float mSpend=15;Paint p;Paint mPaintGrade;MAIN mMain;public FaceView(Context context,int _screenWidth,int _screenHeight) {super(context);mMain =(MAIN) context;// TODO Auto-generated constructor stubmSw=_screenWidth;mSh=_screenHeight;init();}@Overridepublic void surfaceChanged(SurfaceHolder holder, int format, int width,int height) {// TODO Auto-generated method stubnew Thread(mRunnable).start();}@Overridepublic void surfaceCreated(SurfaceHolder holder) {// TODO Auto-generated method stub}@Overridepublic void surfaceDestroyed(SurfaceHolder holder) {// TODO Auto-generated method stubmIs_run=false;}Face face_1,face_2,face_3;Goods mGoods_1,mGoods_2;void init(){p= new Paint();p.setColor(Color.WHITE);mPaintGrade = new Paint();mPaintGrade.setColor(Color.BLACK);mPaintGrade.setTextSize(30);lodingImage();initLocation();mHolder = getHolder();mHolder.addCallback(this);face_1= new Face(m_x1,m_y);face_2= new Face(m_x2,m_y);face_3= new Face(m_x3,m_y);mGoods_1 = new Goods();mGoods_2 = new Goods();}void lodingImage(){mBitmapFaceSmile =BitmapFactory.decodeResource(getResources(), R.drawable.face_smile);mBitmapFaceRefuse =BitmapFactory.decodeResource(getResources(), R.drawable.fac
文档评论(0)