bool MainGameLayer::init() { isLeftTouched = false; isSwipeStart = false; iSwipeStartY = 0; iSwipeEndY = 0; // Touch Director* director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); // box2d physics Box2dDirectorLayer* box2dDL = Box2dDirectorLayer::create(); addChild(box2dDL, 1, kTagLayerBox2dD); // background initBackground(); // HUD initHUD(); // Particles _bladeSparkle = ParticleSystemQuad::create("Particles/blade_sparkle.plist"); _bladeSparkle->stopSystem(); addChild(_bladeSparkle, 3); // Sounds SimpleAudioEngine::getInstance()->preloadEffect("Sounds/swoosh.caf"); SimpleAudioEngine::getInstance()->preloadEffect("Sounds/squash.caf"); SimpleAudioEngine::getInstance()->preloadEffect("Sounds/toss_consecutive.caf"); SimpleAudioEngine::getInstance()->preloadEffect("Sounds/toss_simultaneous.caf"); SimpleAudioEngine::getInstance()->preloadEffect("Sounds/toss_bomb.caf"); SimpleAudioEngine::getInstance()->preloadEffect("Sounds/lose_life.caf"); SimpleAudioEngine::getInstance()->playBackgroundMusic("Sounds/nature_bgm.aifc"); _timeCurrent = 0; //// TMX /*TileMapLayer* tilemapL = TileMapLayer::create(); addChild(tilemapL, 1, kTagTileMap); tilemapL->createWithTMX("grassMap.tmx"); */ //addMissionaries(); // polygon sprite /*PolygonSprite *sprite = (new Watermelon())->initWithWorld(box2dDL->world); addChild(sprite, 1); sprite->activateCollisions();*/ // Raycast //_raycastCallback = new RaycastCallback(); return true; }
//------------------------------------------------------------------ // // MainGameLayer3 // //------------------------------------------------------------------ bool MainGameLayer3::init() { iMaxFeet = MAX_DIVE_FEET_AT_ONE_SCENE; iTagForMarinelife = kTagLayerSquid; // Add background sprite addBackground(); // Touch Director* director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); return true; }
bool SeahorseLayer::init() { isBye = false; byePoint = 0; isHeadToLeft = true; isAttachedToDiver = false; initWithPlist(p_Seahorse, s_Seahorse); //touch Director* director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); return true; }
//------------------------------------------------------------------ // // MainGameLayer // //------------------------------------------------------------------ bool MainGameLayer::init() { if ( !Layer::init() ) { return false; } isRunningEffect = false; //touch Director* director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); addBackground(); return true; }
//------------------------------------------------------------------ // // MainGameLayer2 // //------------------------------------------------------------------ bool MainGameLayer2::init() { iMaxFeet = MAX_DIVE_FEET_AT_ONE_SCENE; iTagForMarinelife = kTagLayerTurtle; // Add background sprite addBackground(); // Touch Director* director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); // ADMOB JNI AdmobJNI::setAdmobVisible(true, true); return true; }
void Layer::onExit() { Director* pDirector = Director::getInstance(); if( _touchEnabled ) { pDirector->getTouchDispatcher()->removeDelegate(this); } // remove this layer from the delegates who concern Accelerometer Sensor if (_accelerometerEnabled) { pDirector->getAccelerometer()->setDelegate(nullptr); } // remove this layer from the delegates who concern the keypad msg if (_keypadEnabled) { pDirector->getKeypadDispatcher()->removeDelegate(this); } Node::onExit(); }
void MainGameLayer::onExit() { Director* director = Director::getInstance(); director->getTouchDispatcher()->removeDelegate(this); Layer::onExit(); }
void TouchesPerformTest1::registerWithTouchDispatcher() { Director* director = Director::getInstance(); director->getTouchDispatcher()->addTargetedDelegate(this, 0, true); }
void TouchesPerformTest2::registerWithTouchDispatcher() { Director* director = Director::getInstance(); director->getTouchDispatcher()->addStandardDelegate(this, 0); }
void TouchesPerformTest1::registerWithTouchDispatcher() { Director* pDirector = Director::sharedDirector(); pDirector->getTouchDispatcher()->addTargetedDelegate(this, 0, true); }
void TouchesPerformTest2::registerWithTouchDispatcher() { Director* pDirector = Director::sharedDirector(); pDirector->getTouchDispatcher()->addStandardDelegate(this, 0); }