环境 cocos2d-x-3.1.1
ios版本
找到 AppController.mm
修改方法 -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 中
[eaglView setMultipleTouchEnabled: YES] 改成[eaglView setMultipleTouchEnabled: false]
android版本
找到
cocos2d-x\cocos\platform\android\java\src\org\cocos2dx\lib\Cocos2dxGLSurfaceView.java
在方法 public boolean onTouchEvent(final MotionEvent pMotionEvent) 中添加两句
switch (pMotionEvent.getAction() & MotionEvent.ACTION_MASK) { case MotionEvent.ACTION_POINTER_DOWN: if (pointerNumber>1) return false;//add 屏蔽多点触摸 final int indexPointerDown = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_INDEX_SHIFT; final int idPointerDown = pMotionEvent.getPointerId(indexPointerDown); final float xPointerDown = pMotionEvent.getX(indexPointerDown); final float yPointerDown = pMotionEvent.getY(indexPointerDown); this.queueEvent(new Runnable() { @Override public void run() { Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleActionDown(idPointerDown,xPointerDown,yPointerDown); } }); break; case MotionEvent.ACTION_DOWN: if (pointerNumber>1) return false;//add 屏蔽多点触摸 // there are only one finger on the screen final int idDown = pMotionEvent.getPointerId(0); final float xDown = xs[0]; final float yDown = ys[0]; this.queueEvent(new Runnable() { @Override public void run() { Cocos2dxGLSurfaceView.this.mCocos2dxRenderer.handleActionDown(idDown,xDown,yDown); } }); break;