What’s the issue?
When I first boot up my game on iOS, touch input isn’t working.
If I tap the screen a few times (like 10 taps), it suddenly starts working without any further issues.
What’s the engine version?
Issue occurred with v3.0 and 3.1 final.
How to reproduce it?
I’m pretty much using default input code, which I start in the onEnter of my GameLayer.
The code works perfectly fine on Android, and even in the iOS simulator on my Mac.
But on the iPad 2 I have, I run into the issue.
Here’s my code:
void GameLayer::onEnter()
{
theLog.WriteLine( "GameLayer=>onEnter" );
cocos2d::CCLayer::onEnter();
// Register Touch Event
auto pEventDispatcher = cocos2d::Director::getInstance()->getEventDispatcher();
if (pEventDispatcher)
{
// Key listener
auto pKeyListener = cocos2d::EventListenerKeyboard::create();
if (pKeyListener)
{
pKeyListener->onKeyPressed = CC_CALLBACK_2(GameLayer::onKeyPressed, this);
pKeyListener->onKeyReleased = CC_CALLBACK_2(GameLayer::onKeyReleased, this);
pEventDispatcher->addEventListenerWithSceneGraphPriority(pKeyListener, this);
}
// Touch listener
auto pTouchListener = cocos2d::EventListenerTouchOneByOne::create();
if (pTouchListener)
{
pTouchListener->setSwallowTouches( true );
pTouchListener->onTouchBegan = CC_CALLBACK_2( GameLayer::onTouchBegan, this );
pTouchListener->onTouchMoved = CC_CALLBACK_2( GameLayer::onTouchMoved, this );
pTouchListener->onTouchEnded = CC_CALLBACK_2( GameLayer::onTouchEnded, this );
pTouchListener->onTouchCancelled = CC_CALLBACK_2( GameLayer::onTouchCancelled, this );
pEventDispatcher->addEventListenerWithSceneGraphPriority( pTouchListener, this );
}
// Accelerometer listener
auto pAccelerationListener = cocos2d::EventListenerAcceleration::create( CC_CALLBACK_2( GameLayer::onAcceleration, this ) );
if (pAccelerationListener) { pEventDispatcher->addEventListenerWithSceneGraphPriority( pAccelerationListener, this ); }
}
}
Does anyone have a clue what could be causing this, or better yet, how to fix it?
Many thanks in advance!
Kind regards,
Michaël