zoukankan      html  css  js  c++  java
  • MotionEvent及惯性

    ACTION_DOWN:

    if(1==isMenuLevel)//一级菜单
    				{
    					if(doorState==1)//当前为开仓状态,并且没有弹出对话框
    					{
    						if(hasInertia)//按下时,如果有惯性,那么直接停止
    						{
    							hasInertia=false;
    							curr_angle_speed=0;
    						}
    						//这里对滚轮菜单下的按下事件进行监听
    						if(x>MENU_BUTTON_AREA[0]&&x<MENU_BUTTON_AREA[1]&&y>MENU_BUTTON_AREA[2]&&y<MENU_BUTTON_AREA[3])
    			        	{
    							isPoint=true;//点击了相应的菜单按钮
    			        	}
    					}
    				}

    ACTION_MOVE:

    					if(doorState==1)//当前为开仓状态,并且没有弹出对话框
    					{
    						//这里进行范围限制
    						if(missile_rotation+dy*TOUCH_SCALE_FACTOR>20)
    						{
    							missile_rotation=20;
    						}
    						else if(missile_rotation+dy*TOUCH_SCALE_FACTOR<-245)
    						{
    							missile_rotation=-245;
    						}
    						else
    						{
    							missile_rotation+=dy*TOUCH_SCALE_FACTOR;//当前导弹菜单旋转地角度
    						}
    						if(Math.abs(dy)>8)//设定一个阈值,如果大于这个阈值,松开手指后,添加惯性
    						{
    							isTouchMoved=true;//当前正在触摸 移动中
    							curr_angle_speed=ori_angle_speed*(dy/SCREEN_WIDTH);
    						}
    						if(isPoint&&Math.abs(dy)>10)//如果点击事件为true,但是又移动了,所以点击事件设为false
    						{
    							isPoint=false;
    						}
    					}

    ACTION_UP:

    if(doorState==1)//当前为开仓状态,并且没有弹出对话框
    					{
    						if(isTouchMoved)//如果当前滑动过
    						{
    							isTouchMoved=false;//false
    							hasInertia=true;//具有惯性true
    							  //若当前角速度大于零则加速度置为负
    							curr_acceleratedSpeed=ori_acceleratedSpeed;
    				            if(curr_angle_speed>0)
    				            {
    				            	curr_acceleratedSpeed=-ori_acceleratedSpeed;
    				            }
    						}
    						else//这里启动角度智能调整
    						{
    							auto_adjust=true;
    						}


  • 相关阅读:
    shell 指定范围产生随机数
    shell脚本比较两个数大小
    Shell 脚本实现随机抽取班级学生
    linux通过挂载系统光盘搭建本地yum仓库的方法
    kuberenetes 上使用helm部署rancher如何卸载干净
    Windows 下 左Ctrl和Caps交换
    C#笔记 -- 协变、逆变
    Python 读取window下UTF-8-BOM 文件
    生成命令行程序使用脚本
    ffmpeg 命令小记
  • 原文地址:https://www.cnblogs.com/Anzhongliu/p/6092077.html
Copyright © 2011-2022 走看看