您好,欢迎光临本网站![请登录][注册会员]  
文件名称: android源码连连看
  所属分类: Android
  开发工具:
  文件大小: 2mb
  下载次数: 0
  上传时间: 2015-08-24
  提 供 者: lll120*******
 详细说明: private void init() { config=new GameConf(8, 9, 1, 10, 100000, this); gameView=(GameView) findViewById(R.id.gameview); timeTextView=(TextView) findViewById(R.id.timeText); startButton=(Button) findViewById(R.id.startButton); dis=soundPool.load(this, R.raw.dis, 1); gameSrvice=new GameServiceImpl(config); gameView.setGameSrvice(gameSrvice); startButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gameView.startGame(); } }); gameView.setOnTouchList ener(new OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { if(isPlaying) { return false; } if(event.getAction()==MotionEvent.ACTION_DOWN) { gameViewTouchDown(event); } if(event.getAction()==MotionEvent.ACTION_UP) { gameViewTouchUp(event); } return true; } }); loseDialog=new AlertDialog.Builder(this); loseDialog.setTitle("Lost"); loseDialog.setMessage("游戏失败了"); loseDialog.setIcon(R.drawable.lost); loseDialog.setPositiveButton("确定", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startGame(config.ENDTIME); } }); sucessDialog=new AlertDialog.Builder(this); sucessDialog.setTitle("Sucess"); sucessDialog.setMessage("游戏成功了"); sucessDialog.setIcon(R.drawable.success); sucessDialog.setPositiveButton("确定", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { startGame(config.ENDTIME); } }); } @Override protected void onPause() { stopTimer(); super.onPause(); } @Override protected void onResume() { // TODO Auto-generated method stub if(isPlaying) { startGame(gameTime); } super.onResume(); } private void stopTimer() { timer.cancel();timer=null; } private void startGame(int endtime) { if(this.timer!=null) { stopTimer(); } gameTime=endtime; if(gameTime==GameConf.ENDTIME) { gameView.startGame(); } isPlaying=true; timer=new Timer(); timer.schedule(new TimerTask() { @Override public void run() { handler.sendEmptyMessage(0x123); } }, 1000); selected=null; } private void gameViewTouchUp(MotionEvent event) { } private void gameViewTouchDown(MotionEvent event) { Piece [][] pieces=gameSrvice.getPiece(); float x=event.getX(); float y=event.getY(); Piece piece=gameSrvice.findPiece(x, y); if(piece==null) { return; } gameView.setSelectedPiece(piece); if(selected==null) { selected=piece; gameView.postInvalidate(); return; } else { LinkInfo linkInfo=gameSrvice.link(selected, piece); if(linkInfo==null) { selected=piece; gameView.postInvalidate(); } else { gameView.setLinkInfo(linkInfo); gameView.setSelectedPiece(null); gameView.postInvalidate(); pieces[piece.getIndexX()][piece.getIndexY()]=null; pieces[selected.getIndexX()][selected.getIndexY()]=null; this.selected=null; soundPool.play(dis,1, 1, 0, 0, 1); if(!gameSrvice.hasPiece()) { sucessDialog.show(); stopTimer();isPlaying=false; } } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: link
 输入关键字,在本站1000多万海量源码库中尽情搜索: