How to disable multitouch

1-how to disable multitouch in cocos 2d-x 2.0.3 for blackberry and android device.
2- how to stop play effect when we replaceing the scene because at that time stopalleffect() not work in blackberry ,and two sound coming together from both the scene.

ASAIK, there is not way to disable multitouch on android devices.
Did you mean stopAllEffects() don’t work on blackberry?

stopAllEffects() normally work but at a time when we replace the scene and go in next scene then it won’t work
when i click in home button (to replace the scene) , call this function

void GameLayer::goToMainMenu()
{

SimpleAudioEngine::sharedEngine()->stopAllEffects();
CCDirector::sharedDirector()->replaceScene(CCTransitionFadeTR::create(0.9f, MainScene::create()));

}

it reach in MainScene then both play effect ,one from GameScene and another from MainScene appear.

I believe there is no way to disable Multi-touch. You’d have to code your game so that it will handle only one touch at a time.

When multi-touching, I believe ccTouchBegan() is being repeated for every touch. You could just create a flag that determines if a touch is already active.

bool TestGame::ccTouchBegan( CCTouch * touch, CCEvent * event ) {
    CC_UNUSED_PARAM( event );

    if ( mTouchFlag ) return false;

    mTouchFlag = true;
    // Other code here.
}

void TestGame::ccTouchEnded( CCTouch * touch, CCEvent * event ) {
    CC_UNUSED_PARAM( event );

    mTouchFlag = false;
}

I’m not sure if this works, though. I’ve never tried it myself. Another solution is to enable multi-touch and only work with one touch at a time.

Thanks Minggo Zhang and Lance Gray.

But Blackberry sound problem i am still unable to solve if any idea then please share

You can get the hash for the touch (aka id in cocos2dx), and keep the hash in stack and verify if it is the same hash in touch moved and ended

@lance_gray
You have somewhat written a good logic for doing the same. But really it doesn’t bring perfection.
In iOS by default multitouch is disabled, so not a problem, but still there is a problem with android. Any solution that have been found? Is there a way to write something in manifest and do the same?

One way is just go to Cocos2dxGLSurfaceView.java file and go to onTouchEvent
Just comment the switch case case MotionEvent.ACTION_POINTER_DOWN:. No need to modify anything else. It worked for me.

//            case MotionEvent.ACTION_POINTER_DOWN:
//                final int indexPointerDown = pMotionEvent.getAction() >> MotionEvent.ACTION_POINTER_ID_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;
```
Cheers
6 Likes

This worked for me as well, thanks! :slight_smile:

Thanks @rajan, it works very fine :slight_smile: .

@yagoub @francismoy My Pleasure

@rajan It also works for me.Thanks.

@komalshah3012
My pleasure