// // AniTutorialMapControl.cpp // SteveMaggieCpp // // Created by Katarzyna Kalinowska-Górska on 17.05.2017. // // #include "AniTutorialMapControl.h" #include "AniMapLayer.h" #include "AniSoundsRepo.h" #include "IMapCharacter.h" #include "AniScalingUtils.h" #include "AniMiscUtils.h" //AniTutorialMapControl::AniTutorialMapControl(){ // //} AniTutorialMapControl::~AniTutorialMapControl(){ } void AniTutorialMapControl::install(AniMapLayer* p_AniMapLayer, IMapCharacter* p_controlledCharacter, std::vector p_observers){ AniTouchRecognizerMapControl::install(p_AniMapLayer, p_controlledCharacter, p_observers); m_AniMapLayer = p_AniMapLayer; m_mapCharacter = p_controlledCharacter; } void AniTutorialMapControl::configureTouchAniGestureRecognizer(AniMapLayer* p_AniMapLayer) { m_multipleTouchAniGestureRecognizer = new AniMultipleTouchGestureRecognizer(); m_multipleTouchAniGestureRecognizer->install(p_AniMapLayer); m_multipleTouchAniGestureRecognizer->changeTouchListenerPriorityToSceneGraphPriority(); m_multipleTouchAniGestureRecognizer->setOnSingleTouchDetectedCallback([&](AniGestureRecognizer::TouchData touchData){ if(m_tutorialPhase == TutorialPhase::TAP_OBJECT){ auto objects = m_AniMapLayer->getMapController()->getAdventureObjectsAtTouchPoint(touchData.currentTouchLocation); if(objects.size() > 0){ auto slide = dynamic_cast(objects[0]); if(slide != nullptr){ auto event = new TappedSlideEvent(slide, m_AniMapLayer->getMapController()->getTileForTouchPoint(touchData.currentTouchLocation)); mapEvent(nullptr, event); delete event; } } } if(m_tutorialPhase != TutorialPhase::MOVE_STEVE && m_tutorialPhase != TutorialPhase::TAP_OBJECT){ return; } IMapControlSingleXYEventData eventData {touchData.touchId, touchData.currentTouchLocation, touchData.previousTouchLocation, touchData.initialTouchLocation}; for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandSingleXYPress(eventData); } // cocos2d::log("touch point on screen: %f\n", touchData.currentTouchLocation.x); }); m_multipleTouchAniGestureRecognizer->setOnSingleTouchMovedCallback([&](AniGestureRecognizer::TouchData touchData){ if(m_tutorialPhase != TutorialPhase::MOVE_STEVE && m_tutorialPhase != TutorialPhase::TAP_OBJECT){ return; } IMapControlSingleXYEventData eventData {touchData.touchId, touchData.currentTouchLocation, touchData.previousTouchLocation, touchData.initialTouchLocation}; for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandSingleXYMove(eventData); } }); m_multipleTouchAniGestureRecognizer->setOnSingleTouchEndedCallback([&](AniGestureRecognizer::TouchData touchData){ if(m_tutorialPhase != TutorialPhase::MOVE_STEVE && m_tutorialPhase != TutorialPhase::TAP_OBJECT){ return; } IMapControlSingleXYEventData eventData {touchData.touchId, touchData.currentTouchLocation, touchData.previousTouchLocation, touchData.initialTouchLocation}; for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandSingleXYRelease(eventData); } }); m_multipleTouchAniGestureRecognizer->setOnMultipleTouchDetectedCallback([&](std::vector touches){ if(m_tutorialPhase != TutorialPhase::PRE_ZOOM && m_tutorialPhase != TutorialPhase::ZOOM){ return; } std::vector touchesData; for(auto touchIt = touches.begin(); touchIt != touches.end(); ++touchIt){ touchesData.push_back({touchIt->touchId, touchIt->currentTouchLocation, touchIt->previousTouchLocation, touchIt->initialTouchLocation}); } for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandMultipleXYPress(touchesData); } }); m_multipleTouchAniGestureRecognizer->setOnMultipleTouchMovedCallback([&](std::vector touches){ if(m_tutorialPhase != TutorialPhase::PRE_ZOOM && m_tutorialPhase != TutorialPhase::ZOOM){ return; } std::vector touchesData; for(auto touchIt = touches.begin(); touchIt != touches.end(); ++touchIt){ touchesData.push_back({touchIt->touchId, touchIt->currentTouchLocation, touchIt->previousTouchLocation, touchIt->initialTouchLocation}); } for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandMultipleXYMove(touchesData); } }); m_multipleTouchAniGestureRecognizer->setOnMultipleTouchEndedCallback([&](std::vector touches){ if(m_tutorialPhase != TutorialPhase::PRE_ZOOM && m_tutorialPhase != TutorialPhase::ZOOM){ return; } std::vector touchesData; for(auto touchIt = touches.begin(); touchIt != touches.end(); ++touchIt){ touchesData.push_back({touchIt->touchId, touchIt->currentTouchLocation, touchIt->previousTouchLocation, touchIt->initialTouchLocation}); } for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandMultipleXYRelease(touchesData); } }); } using AniGestureRecognizerDirection = AniFastSwipeGestureRecognizer::AniGestureRecognizerDirection; void AniTutorialMapControl::configureAniFastSwipeGestureRecognizer(cocos2d::Node* p_controlledCharacter) { m_AniFastSwipeGestureRecognizer = new AniFastSwipeGestureRecognizer(); m_AniFastSwipeGestureRecognizer->install(p_controlledCharacter); m_AniFastSwipeGestureRecognizer->changeTouchListenerPriorityToSceneGraphPriority(); m_AniFastSwipeGestureRecognizer->setOnFastSwipeDetectedCallback([&](AniGestureRecognizerDirection directionX, AniGestureRecognizerDirection directionY, cocos2d::Point startLocation, cocos2d::Point endLocation, float speedX, float speedY){ if(m_tutorialJumpSubPhaseJumping){ return; } if(m_tutorialPhase != TutorialPhase::JUMP_UP && m_tutorialPhase != TutorialPhase::JUMP_DOWN && m_tutorialPhase != TutorialPhase::JUMP_LEFT && m_tutorialPhase != TutorialPhase::JUMP_RIGHT){ return; } if(m_tutorialPhase == TutorialPhase::JUMP_UP && directionY != AniGestureRecognizerDirection::UP){ return; } if(m_tutorialPhase == TutorialPhase::JUMP_DOWN && directionY != AniGestureRecognizerDirection::DOWN){ return; } if(m_tutorialPhase == TutorialPhase::JUMP_RIGHT && directionX != AniGestureRecognizerDirection::RIGHT){ return; } if(m_tutorialPhase == TutorialPhase::JUMP_LEFT && directionX != AniGestureRecognizerDirection::LEFT){ return; } // m_tutorialJumpSubPhaseJumping = true; int intDirX = 0; int intDirY = 0; if(directionY == AniGestureRecognizerDirection::UP) intDirY = 1; else if (directionY == AniGestureRecognizerDirection::DOWN) intDirY = -1; if(directionX == AniGestureRecognizerDirection::RIGHT) intDirX = 1; else if (directionX == AniGestureRecognizerDirection::LEFT) intDirX = -1; IMapControlSwipeEventData eventData {1, startLocation, endLocation, {speedX, speedY}, intDirX, intDirY}; for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandFastSwipe(eventData); } }); } void AniTutorialMapControl::configureAniTickleGestureRecognizer(IMapCharacter* p_controlledCharacter) { m_tickleAniGestureRecognizer = new Tickle2GestureRecognizer(); m_tickleAniGestureRecognizer->install(p_controlledCharacter); m_tickleAniGestureRecognizer->changeTouchListenerPriorityToSceneGraphPriority(); m_tickleAniGestureRecognizer->setOnTicklingStartedCallback([&](){ if(m_tutorialPhase != TutorialPhase::TICKLE){ return; } for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandTicklingStarted(); } }); m_tickleAniGestureRecognizer->setOnTicklingCallback([&](){ if(m_tutorialPhase != TutorialPhase::TICKLE){ return; } for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandTicklingContinued(); } }); m_tickleAniGestureRecognizer->setOnTicklingEndedCallback([&](){ // if(m_tutorialPhase != TutorialPhase::TICKLE){ // return; // } for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ (*it)->handleCommandTicklingEnded(); } }); } void AniTutorialMapControl::configureAniTapGestureRecognizer(AniMapLayer* p_AniMapLayer) { m_AniTapGestureRecognizer = new AniTapGestureRecognizer(); m_AniTapGestureRecognizer->install(p_AniMapLayer); m_AniTapGestureRecognizer->changeTouchListenerPriorityToSceneGraphPriority(); m_AniTapGestureRecognizer->setOnTapDetectedCallback([&](cocos2d::Point tapLocation){ if(m_tutorialPhase != TutorialPhase::ZOOM){ return; } IMapControlSingleXYEventData eventData {1, tapLocation, {-1,-1}, tapLocation}; for(auto it = m_observers.begin(); it != m_observers.end(); ++it){ auto mapController = dynamic_cast(*it); if(mapController != nullptr){ mapController->handleCommandSingleXYTap(eventData); } } }); } void AniTutorialMapControl::configureAniLongPressGestureRecognizer(IMapCharacter* p_controlledCharacter) { // not needed } void AniTutorialMapControl::mapEvent(IMapControlInterface* p_controlInterface, IMapEvent* p_mapEvent){ if (m_tutorialPhase == TutorialPhase::MOVE_STEVE && p_mapEvent->type == "CharacterChangeTileEvent") { auto moveEvent = static_cast(p_mapEvent); auto endTiles = m_tutorialDataSource->mapTilesForMoveSteveEnd(this); if(std::find(endTiles.begin(), endTiles.end(), moveEvent->characterTile) != endTiles.end()){ m_mapCharacter->getController()->disableCharacterMovement(); IMapControlSingleXYEventData mockData {1, cocos2d::Point::ZERO, cocos2d::Point::ZERO, cocos2d::Point::ZERO}; p_controlInterface->handleCommandSingleXYRelease(mockData); praiseAndNextPhase([&](){ startTapObjectPhase(); }); } } else if(m_tutorialPhase == TutorialPhase::TAP_OBJECT){ if(p_mapEvent->type == "TappedSlideEvent"){ m_tutorialPhase = TutorialPhase::APPROACHING_SLIDE; m_mapCharacter->getController()->enableCharacterMovement(); auto slideEvent = static_cast(p_mapEvent); m_mapCharacter->getController()->approachAdventureObject(slideEvent->slide, slideEvent->tappedTile); } else if(p_mapEvent->type == "CharacterStartedSlidingEvent"){ m_tutorialPhase = TutorialPhase::SLIDE; AniSoundsRepo::playSound(AniSoundsRepo::hooraySound().filePath); hideFinger(); } } else if(p_mapEvent->type == "CharacterFinishedSlidingEvent"){ moveToJumpingSpot(); } else if(p_mapEvent->type == "CharacterStartedJumpingEvent"){ m_tutorialJumpSubPhaseJumping = true; } else if(p_mapEvent->type == "CharacterFinishedJumpingEvent"){ if(m_tutorialPhase == TutorialPhase::JUMP_UP){ praiseAndNextPhase([&](){ startJumpDownPhase(); }); } else if(m_tutorialPhase == TutorialPhase::JUMP_DOWN){ praiseAndNextPhase([&](){ startJumpRightPhase(); }); } else if(m_tutorialPhase == TutorialPhase::JUMP_RIGHT){ praiseAndNextPhase([&](){ startJumpLeftPhase(); }); } else if(m_tutorialPhase == TutorialPhase::JUMP_LEFT){ praiseAndNextPhase([&](){ startTicklePhase(); }); } } else if(m_tutorialPhase == TutorialPhase::TICKLE && p_mapEvent->type == "CharacterFinishedLaughingEvent"){ praiseAndNextPhase([&](){ startMapMovePhase(); }); } else if(m_tutorialPhase == TutorialPhase::PRE_ZOOM && p_mapEvent->type == "MapFinishedMovingEvent"){ praiseAndNextPhase([&](){ startMapTapToCancelMovePhase(); }); } else if(m_tutorialPhase == TutorialPhase::ZOOM && p_mapEvent->type == "MapTappedToFinishMovingEvent"){ m_tutorialPhase = TutorialPhase::POST_ZOOM; praiseAndNextPhase([&](){ finishTutorial(); }); } } void AniTutorialMapControl::startTutorial(){ m_tutorialPhase = TutorialPhase::MOVE_STEVE; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseMove(this, soundDuration)); setDarknessRevealParams(cocos2d::Point(1200, 600), 800); //TODO from the tutorial data source auto cameraCutHeight = cocos2d::Director::getInstance()->getWinSize().height*1.1f; auto cameraMinY = m_mapCharacter->getBoundingBox().getMidY() - cameraCutHeight/2; auto cameraMaxX = m_AniMapLayer->getMapController()->getMapImageObject("slide1Front")->getBoundingBox().getMaxX(); m_AniMapLayer->getMapController()->setCameraCut(cocos2d::Rect(0, cameraMinY, cameraMaxX, cameraCutHeight)); blinkFingerAtMapLocation(m_tutorialDataSource->mapPointForMoveSteveFinger(this)); } void AniTutorialMapControl::forceFinishTutorial(){ m_AniMapLayer->unschedule("nextPhase"); AniSoundsRepo::stopAllSounds(); finishTutorial(true); } void AniTutorialMapControl::startTapObjectPhase(){ m_tutorialPhase = TutorialPhase::TAP_OBJECT; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseTapObject(this, soundDuration)); // float scale = AniScalingUtils::scaleAspectFitToDesignIpadProSize(); auto cameraCutHeight = cocos2d::Director::getInstance()->getWinSize().height; auto cameraMinY = m_mapCharacter->getPositionY() - cameraCutHeight/2; auto slideBB = m_AniMapLayer->getMapController()->getMapImageObject("slide1Front")->getBoundingBox(); auto cameraMidX = slideBB.getMidX(); auto cameraCutWidth = cocos2d::Director::getInstance()->getWinSize().width*1.4f; m_AniMapLayer->getMapController()->setCameraCut(cocos2d::Rect(cameraMidX - cameraCutWidth/2, cameraMinY, cameraMidX + cameraCutWidth/2, cocos2d::Director::getInstance()->getWinSize().height)); // m_AniMapLayer->getMapController()->cancelCameraCut(); auto slidePoint = m_tutorialDataSource->mapPointForTapObjectFinger(this); m_AniMapLayer->getMapController()->revealTilesInRadius(slidePoint, slideBB.size.width/2, slideBB.size.height/2); blinkFingerAtMapLocation(slidePoint); } void AniTutorialMapControl::moveToJumpingSpot(){ m_tutorialPhase = TutorialPhase::MOVE_TO_JUMP_SPOT; m_mapCharacter->getController()->moveCharacterToTile({20,11}, [&](){ startJumpUpPhase(); }); } void AniTutorialMapControl::startJumpUpPhase(){ m_tutorialPhase = TutorialPhase::JUMP_UP; m_tutorialJumpSubPhaseJumping = false; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseJumpUp(this, soundDuration)); m_AniMapLayer->getMapController()->cancelCameraCut(); swipeFingerAtMapLocations({m_mapCharacter->getBoundingBox().getMidX(), m_mapCharacter->getBoundingBox().getMidY() - m_mapCharacter->getBoundingBox().size.height*0.3f}, {m_mapCharacter->getBoundingBox().getMidX(), m_mapCharacter->getBoundingBox().getMidY() + m_mapCharacter->getBoundingBox().size.height*0.3f}, 0.3f, 0.2f); } void AniTutorialMapControl::startJumpDownPhase(){ m_tutorialPhase = TutorialPhase::JUMP_DOWN; m_tutorialJumpSubPhaseJumping = false; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseJumpDown(this, soundDuration)); swipeFingerAtMapLocations({m_mapCharacter->getBoundingBox().getMidX(), m_mapCharacter->getBoundingBox().getMidY() + m_mapCharacter->getBoundingBox().size.height*0.4f}, {m_mapCharacter->getBoundingBox().getMidX(), m_mapCharacter->getBoundingBox().getMidY() - m_mapCharacter->getBoundingBox().size.height*0.2f}, 0.3f, 0.2f); } void AniTutorialMapControl::startJumpLeftPhase(){ m_tutorialPhase = TutorialPhase::JUMP_LEFT; m_tutorialJumpSubPhaseJumping = false; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseJumpLeft(this, soundDuration)); swipeFingerAtMapLocations({m_mapCharacter->getBoundingBox().getMidX(), m_mapCharacter->getBoundingBox().getMidY()}, {m_mapCharacter->getBoundingBox().getMidX() - m_mapCharacter->getBoundingBox().size.width, m_mapCharacter->getBoundingBox().getMidY()}, 0.3f, 0.2f); } void AniTutorialMapControl::startJumpRightPhase(){ m_tutorialPhase = TutorialPhase::JUMP_RIGHT; m_tutorialJumpSubPhaseJumping = false; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseJumpRight(this, soundDuration)); swipeFingerAtMapLocations({m_mapCharacter->getBoundingBox().getMidX(), m_mapCharacter->getBoundingBox().getMidY()}, {m_mapCharacter->getBoundingBox().getMidX() + m_mapCharacter->getBoundingBox().size.width, m_mapCharacter->getBoundingBox().getMidY()}, 0.3f, 0.2f); } void AniTutorialMapControl::startTicklePhase(){ m_tutorialPhase = TutorialPhase::TICKLE; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseTickle(this, soundDuration)); moveFingerBackAndForthAtMapLocations({m_mapCharacter->getBoundingBox().getMidX()-m_mapCharacter->getBoundingBox().size.width/10, m_mapCharacter->getBoundingBox().getMidY() - m_mapCharacter->getBoundingBox().size.height/10}, {m_mapCharacter->getBoundingBox().getMidX() + m_mapCharacter->getBoundingBox().size.width/10, m_mapCharacter->getBoundingBox().getMidY() + m_mapCharacter->getBoundingBox().size.height/10}, 0.1f, 0.f); } void AniTutorialMapControl::startMapMovePhase(){ m_tutorialPhase = TutorialPhase::PRE_ZOOM; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseMoveMap(this, soundDuration)); if(m_finger != nullptr){ m_finger->removeFromParent(); } m_finger = cocos2d::Sprite::create("graphics/tutorials/graphics/fingers_two.png"); m_AniMapLayer->addChild(m_finger); m_finger->setAnchorPoint(cocos2d::Vec2(0.25, 0.9)); auto winSize = cocos2d::Director::getInstance()->getWinSize(); auto center = m_mapCharacter->getPosition(); swipeFingerAtMapLocations({center.x - winSize.width/4, center.y}, {center.x, center.y}, 1.8f, 1.f); } void AniTutorialMapControl::startMapTapToCancelMovePhase(){ m_tutorialPhase = TutorialPhase::ZOOM; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForPhaseTapToFinishMovingMap(this, soundDuration)); if(m_finger != nullptr){ m_finger->removeFromParent(); } m_finger = cocos2d::Sprite::create("graphics/tutorials/graphics/finger_one.png"); m_AniMapLayer->addChild(m_finger); m_finger->setAnchorPoint(cocos2d::Vec2(0.25, 0.9)); m_finger->setRotation(20); m_finger->setOpacity(0); blinkFingerAtScreenLocation(m_tutorialDataSource->cancelZoomButtonPosition(this)); } void AniTutorialMapControl::finishTutorial(bool silent){ // if tutorial already finished (but probably talking) if(m_tutorialPhase == TutorialPhase::FINISHED){ return; } if(m_tutorialPhase == TutorialPhase::FINISHING){ m_AniMapLayer->unschedule("finishTutorialSelector"); AniSoundsRepo::stopAllSounds(); m_tutorialPhase = TutorialPhase::FINISHED; if(m_tutorialDelegate != nullptr){ m_tutorialDelegate->tutorialFinished(this); } } else { m_AniMapLayer->getMapController()->cancelCameraCut(); if(m_finger != nullptr){ m_finger->stopAllActions(); m_finger->removeFromParent(); m_finger = nullptr; } if(silent){ m_tutorialPhase = TutorialPhase::FINISHED; if(m_tutorialDelegate != nullptr){ m_tutorialDelegate->tutorialFinished(this); } } else { m_tutorialPhase = TutorialPhase::FINISHING; int soundDuration; AniSoundsRepo::playSound(m_tutorialDataSource->soundPathForTutorialFinished(this, soundDuration)); m_AniMapLayer->scheduleOnce([&](float){ m_tutorialPhase = TutorialPhase::FINISHED; if(m_tutorialDelegate != nullptr){ m_tutorialDelegate->tutorialFinished(this); } }, soundDuration, "finishTutorialSelector"); } } } void AniTutorialMapControl::praiseAndNextPhase(std::function nextPhaseFunction){ hideFinger(); AniSoundsRepo::playSound(AniSoundsRepo::hooraySound().filePath); m_AniMapLayer->scheduleOnce([=](float){ nextPhaseFunction(); }, 1.8f, "nextPhase"); } void AniTutorialMapControl::blinkFingerAtMapLocation(cocos2d::Vec2 p_mapLocation){ if(m_finger == nullptr){ m_finger = cocos2d::Sprite::create("graphics/tutorials/graphics/finger_one.png"); m_AniMapLayer->addChild(m_finger); m_finger->setAnchorPoint(cocos2d::Vec2(0.25, 0.9)); } else { m_finger->stopAllActions(); m_finger->setVisible(true); if(m_finger->getParent() != m_AniMapLayer){ m_finger->removeFromParent(); m_AniMapLayer->addChild(m_finger); } } m_finger->setPosition(p_mapLocation); m_finger->runAction(cocos2d::RepeatForever::create(cocos2d::Blink::create(10, 10))); } void AniTutorialMapControl::blinkFingerAtScreenLocation(cocos2d::Vec2 p_screenLocation){ if(m_finger == nullptr){ m_finger = cocos2d::Sprite::create("graphics/tutorials/graphics/finger_one.png"); //todo function prepareFingerIfNeeded() m_finger->setAnchorPoint(cocos2d::Vec2(0.25, 0.9)); m_AniMapLayer->getParent()->addChild(m_finger); } else { m_finger->stopAllActions(); // m_finger->setOpacity(255); m_finger->setVisible(true); if(m_finger->getParent() != m_AniMapLayer->getParent()){ m_finger->removeFromParent(); m_AniMapLayer->getParent()->addChild(m_finger); } } m_finger->setOpacity(0); m_finger->setPosition(p_screenLocation); m_finger->runAction(cocos2d::Sequence::create(cocos2d::FadeIn::create(AniMiscUtils::StandardAnimationTime), cocos2d::CallFunc::create([&](){ m_finger->runAction(cocos2d::RepeatForever::create(cocos2d::Blink::create(10, 10))); }), nullptr)); } void AniTutorialMapControl::swipeFingerAtMapLocations(cocos2d::Vec2 p_mapLocationFrom, cocos2d::Vec2 p_mapLocationTo, float moveTime, float pauseTime){ if(m_finger == nullptr){ m_finger = cocos2d::Sprite::create("graphics/tutorials/graphics/finger_one.png"); m_AniMapLayer->addChild(m_finger); m_finger->setAnchorPoint(cocos2d::Vec2(0.25, 0.9)); } else { m_finger->stopAllActions(); if(m_finger->getParent() != m_AniMapLayer){ m_finger->removeFromParent(); m_AniMapLayer->addChild(m_finger); } } m_finger->setOpacity(255); m_finger->setVisible(true); m_finger->setRotation(-45); m_finger->setPosition(p_mapLocationFrom); auto moveAction = cocos2d::Sequence::create(cocos2d::FadeIn::create(AniMiscUtils::StandardAnimationTime), cocos2d::EaseInOut::create( cocos2d::MoveTo::create(0.3f, p_mapLocationTo), 1.2), cocos2d::DelayTime::create(0.2f), cocos2d::FadeOut::create(AniMiscUtils::StandardAnimationTime), cocos2d::CallFunc::create([&, p_mapLocationFrom](){ m_finger->setPosition(p_mapLocationFrom); }), cocos2d::FadeIn::create(AniMiscUtils::StandardAnimationTime), nullptr); m_finger->runAction(cocos2d::RepeatForever::create(moveAction)); } void AniTutorialMapControl::moveFingerBackAndForthAtMapLocations(cocos2d::Vec2 p_mapLocationFrom, cocos2d::Vec2 p_mapLocationTo, float moveTime, float pauseTime){ if(m_finger == nullptr){ m_finger = cocos2d::Sprite::create("graphics/tutorials/graphics/finger_one.png"); m_AniMapLayer->addChild(m_finger); m_finger->setAnchorPoint(cocos2d::Vec2(0.25, 0.9)); } else { m_finger->stopAllActions(); } m_finger->setOpacity(255); m_finger->setVisible(true); m_finger->setRotation(-45); m_finger->setPosition(p_mapLocationFrom); auto moveAction = cocos2d::Sequence::create(cocos2d::MoveTo::create(moveTime, p_mapLocationTo), cocos2d::DelayTime::create(pauseTime), cocos2d::MoveTo::create(moveTime, p_mapLocationFrom), nullptr); m_finger->runAction(cocos2d::RepeatForever::create(moveAction)); } void AniTutorialMapControl::hideFinger(){ if(m_finger != nullptr){ m_finger->stopAllActions(); m_finger->setVisible(false); } } //void AniSubGameSceneShoot::tut_moveFinger(const cocos2d::Point& startPosition, const cocos2d::Point& endPosition, float moveTime, float pauseTime, bool loop, std::function completion){ // if(!tutorialComplete()){ // tut_prepareFingerIfNeeded(); // hintFingerSprite->setPosition(startPosition); // auto moveAction = cocos2d::Sequence::create(cocos2d::FadeIn::create(AniMiscUtils::StandardAnimationTime), // cocos2d::EaseInOut::create( // cocos2d::MoveTo::create(moveTime, endPosition), 1.2), // cocos2d::DelayTime::create(pauseTime), // cocos2d::FadeOut::create(AniMiscUtils::StandardAnimationTime), // cocos2d::CallFunc::create([&, startPosition](){ // hintFingerSprite->setPosition(startPosition); // }), // cocos2d::FadeIn::create(AniMiscUtils::StandardAnimationTime), // nullptr); // if(loop){ // hintFingerSprite->runAction(cocos2d::RepeatForever::create(moveAction)); // } else { // hintFingerSprite->runAction(cocos2d::Sequence::create(moveAction, cocos2d::CallFunc::create(completion), nullptr)); // } // } //} //void AniSubGameSceneShoot::tut_moveFingerBackAndForth(const cocos2d::Point& startPosition, const cocos2d::Point& endPosition, float moveTime, float pauseTime){ // if(!tutorialComplete()){ // tut_prepareFingerIfNeeded(); // hintFingerSprite->setPosition(startPosition); // auto moveAction = cocos2d::Sequence::create(cocos2d::FadeIn::create(AniMiscUtils::StandardAnimationTime), // cocos2d::EaseInOut::create( // cocos2d::MoveTo::create(moveTime, endPosition), 1.2), // cocos2d::DelayTime::create(pauseTime), // cocos2d::EaseInOut::create( // cocos2d::MoveTo::create(moveTime, startPosition), 1.2), // nullptr); // hintFingerSprite->runAction(cocos2d::RepeatForever::create(moveAction)); // } //} // //void AniSubGameSceneShoot::tut_prepareFingerIfNeeded(){ // if(hintFingerSprite == nullptr) { // hintFingerSprite = cocos2d::Sprite::create( // "graphics/g_finger.png"); // addChild(hintFingerSprite, 190); // hintFingerSprite->setAnchorPoint(cocos2d::Vec2(0.4f, 14/15.f)); //TODO fixed // hintFingerSprite->setRotation(-45); // hintFingerSprite->setColor(cocos2d::Color3B(200, 200, 200)); // } else { // hintFingerSprite->stopAllActions(); // hintFingerSprite->setVisible(true); // } //} // //void AniSubGameSceneShoot::tut_hideFinger(bool remove){ // if(hintFingerSprite != nullptr){ // hintFingerSprite->stopAllActions(); // if(remove){ // AniMiscUtils::hideAndRemoveView(hintFingerSprite, true); // hintFingerSprite = nullptr; // } else { // AniMiscUtils::hideView(hintFingerSprite, true); // } // } //} void AniTutorialMapControl::setDarknessRevealParams(cocos2d::Vec2 p_revealCircleMiddle, float p_revealCircleRadius){ // if(m_darknessNode != nullptr){ // m_darknessNode->setRayRadius(p_revealCircleRadius); // m_darknessNode->castRay(p_revealCircleMiddle); // } }