// // ToySceneWithUtils.h // SteveMaggieCpp // // Created by Katarzyna Kalinowska-Górska on 11.05.2017. // // #ifndef ToySceneWithUtils_h #define ToySceneWithUtils_h #include "cocos2d.h" class ToySceneWithUtils : public cocos2d::Scene { public: // enums typedef enum AnimationType { NONE, SCALE_DOWN, SCALE_UP, FADE_OUT, FADE_IN } AnimationType; static const std::string BG_MUSIC_PLAYING_USER_DEFAULTS_KEY; // presenting dialogs virtual void presentDialog(cocos2d::Node* dialogView, AnimationType presentAnimationType, AnimationType dismissAnimationType, const std::function presentCallback = [](){}); virtual void presentDialog(cocos2d::Node* dialogView, AnimationType presentAnimationType, AnimationType dismissAnimationType, cocos2d::Point dialogViewPosition, cocos2d::Point dialogViewAnchorPoint, const std::function presentCallback = [](){}); virtual void dismissCurrentDialog(); virtual void dismissCurrentDialog(const std::function dismissCallback); virtual void presetDialogDismissCallback(const std::function dismissCallback); static AnimationType animationTypeFromString(std::string animationType); // other virtual void setScenePresentCallback(std::function callback); virtual void setSceneDismissCallback(std::function callback); // overrides virtual bool init() override; virtual void onEnterTransitionDidFinish() override; virtual void onExit() override; protected: cocos2d::Node* _currentDialogView; ToySceneWithUtils::AnimationType _dialogDismissAnimationType; std::function _dialogDismissCallback; std::function _dialogPresentCallback; std::function _fullDismissCallback; bool _touchOutsideDismissesDialog; cocos2d::Node* _currentLoadingView; std::string _backgroundMusicFilePath; std::function _scenePresentCallback; std::function _sceneDismissCallback; virtual void _animateDialogView(cocos2d::Node* dialogView, AnimationType animationType, const std::function& callback); }; #endif /* ToySceneWithUtils_h */