开发工具:
文件大小: 9mb
下载次数: 0
上传时间: 2012-11-13
详细说明: 一款经典的手机游戏(植物大战僵尸)的源码 package FreeIMUST.PvZ_Online.PvZ; import FreeIMUST.PvZ_Online.PvZ.PvZ_OnlineActivity.MusicFactory; import FreeIMUST.PvZ_Online.PvZ.PvZ_OnlineActivity.OtherFactory; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.os.Handler; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.SurfaceHolder; import android.view.SurfaceView; public class AboutView extends SurfaceView implements SurfaceHolder.Callback { Bitmap aboutImage_ = null; PvZ_OnlineActivity activity_ = null; RefreshThread refreshThread_ = null; Paint paint_ = new Paint(); Handler handler_ = null; ProcessView processView_ = null; private MIDIPlayer menu_view_mMIDIPlayer = null; public AboutView(PvZ_OnlineActivity activity) { super(activity); activity_ = activity; initBitmap(); getHolder().addCallback(this); this.refreshThread_ = new RefreshThread(getHolder(), this); if(this.activity_.hasBackgroundMusic()) { menu_view_mMIDIPlayer = this.activity_.musicFactory_.getMusicPlayer( MusicFactory.Background_MenuView); menu_view_mMIDIPlayer.PlayMusic(); } } private void initBitmap() { aboutImage_ = activity_.otherFactory_.getImage(OtherFactory.Background_MainMenu_About); } protected void onDraw(Canvas canvas) { super.onDraw(canvas); canvas.drawBitmap(this.aboutImage_, 0, 0, paint_); } public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { } public void surfaceCreated(SurfaceHolder holder) { this.refreshThread_.setFlag(true); this.refreshThread_.start(); } public void surfaceDestroyed(SurfaceHolder holder) { boolean retry = true; refreshThread_.setFlag(false); while (retry) { try { refreshThread_.join(); retry = false; } catch (InterruptedException e) { } } } public boolean onTouchEvent(MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if(this.activity_.hasBackgroundMusic()) this.menu_view_mMIDIPlayer.FreeMusic(); int x = (int) event.getX(); int y = (int) event.getY(); if (x >=0 && x <= 480 && y >= 140 && y <= 190) activity_.myHandler_.sendEmptyMessage(PvZ_OnlineActivity.Message_MainMenu_VisitWeb); activity_.myHandler_.sendEmptyMessage(PvZ_OnlineActivity.Message_MainMenu); } return super.onTouchEvent(event); } public boolean onKeyDown(int keyCode, KeyEvent event) { if (KeyEvent.KEYCODE_BACK == keyCode) { if(this.activity_.hasBackgroundMusic()) this.menu_view_mMIDIPlayer.FreeMusic(); activity_.myHandler_.sendEmptyMessage(PvZ_OnlineActivity.Message_MainMenu); } return super.onKeyDown(keyCode, event); } /////////////////////////////////////////////////////////////////////////////// class RefreshThread extends Thread { SurfaceHolder surfaceHolder_ = null; AboutView aboutView_ = null; boolean flag_ = false; public RefreshThread(SurfaceHolder surfaceHolder, AboutView aboutView) { this.surfaceHolder_ = surfaceHolder; this.aboutView_ = aboutView; } public void setFlag(boolean flag) { this.flag_ = flag; } public void run() { Canvas canvas; while (this.flag_) { canvas = null; try { // 锁定整个画布,在内存要求比较高的情况下,建议参数不要为null canvas = this.surfaceHolder_.lockCanvas(null); synchronized (this.surfaceHolder_) { aboutView_.onDraw(canvas); } } finally { if (canvas != null) this.surfaceHolder_.unlockCanvasAndPost(canvas); } } } } // RefreshThread } ...展开收缩
(系统自动生成,下载前可以参看下载内容)
下载文件列表
相关说明
- 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
- 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度。
- 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
- 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
- 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
- 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.