易采下载站下载Android游戏心跳效果安卓APP开发源代码—源码之家-易采下载站

下载排行|最近更新

软件
软件
文章
当前位置:首页安卓源码安卓特效 → Android游戏心跳效果安卓APP开发源代码
Android游戏心跳效果安卓APP开发源代码

Android游戏心跳效果安卓APP开发源代码

下载地址
  • 软件介绍
  • 软件截图
  • 猜你喜欢
  • 同类推荐
  • 相关文章

软件Tags:

Android游戏心跳效果安卓APP开发源代码

Android游戏心跳效果源代码介绍:开发的游戏中计时就要结束的时候,为了营造紧张的气氛,会利用手机自身的震动模拟心跳效果,其实这个心跳效果做起来真的非常的简单。所以直接上代码了(注意模拟器是模拟不了震动的,得真机测试哦)[code]package com.ray.test;import android.app.Activity;import android.os.Bundle;import android.os.Vibrator;import android.view.MotionEvent;public class TestViberation extends Activity {Vibrator vibrator;/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.main);}@Overrideprotected void onStop() {if(null!=vibrator){vibrator.cancel();}super.onStop();}@Overridepublic boolean onTouchEvent(MotionEvent event) {if(event.getAction() == MotionEvent.ACTION_DOWN){vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);long[] pattern = {800, 50, 400, 30}; // OFF/ON/OFF/ON...vibrator.vibrate(pattern, 2);//-1不重复,非-1为从pattern的指定下标开始重复}return super.onTouchEvent(event);}}[/code]

展开内容

下载地址

推荐文章

友情链接关于我们下载帮助(?)联系我们投诉举报

CopyRight © 2010-2023 易采下载 Easck.com , All Rights Reserved 版权所有 蒙ICP备14002389号

声明: 本站所有软件和文章来自互联网 如有异议 请与本站联系

声明: