1,GamePauseUtils.h
//// GamePauseUtils.h// AdventureKing//// Created by jianan on 15/5/12.////#ifndef __AdventureKing__GamePauseUtils__#define __AdventureKing__GamePauseUtils__#include "cocos2d.h"USING_NS_CC;// *** 作类型typedef enum OPERATE_TYPE{ OPERATE_TYPE_PAUSE,OPERATE_TYPE_RESUME}OPERATE_TYPE;//class GamePauseUtils{public: GamePauseUtils(); ~GamePauseUtils(); static GamePauseUtils* getInstance(); voID operateallSchedulerAndActions(Node* node,OPERATE_TYPE type,int ignoreTag); //忽略检测的tag};#endif /* defined(__AdventureKing__GamePauseUtils__) */
2,GamePauseUtils.cpp
//// GamePauseUtils.cpp// AdventureKing//// Created by jianan on 15/5/12.////#include "GamePauseUtils.h"static GamePauseUtils* instance = NulL;GamePauseUtils::GamePauseUtils(){ }GamePauseUtils::~GamePauseUtils(){ }GamePauseUtils* GamePauseUtils::getInstance(){ if(instance == NulL){ instance = new GamePauseUtils(); } return instance;}voID GamePauseUtils::operateallSchedulerAndActions(Node* node,int ignoreTag){ if(node->isRunning()){ switch(type){ case OPERATE_TYPE_PAUSE: node->pause(); break; case OPERATE_TYPE_RESUME: node->resume(); break; } Vector<Node*> array = node->getChildren(); if(array.size() > 0){ for(Vector<Node*>::iterator iter = array.begin(); iter != array.end();){ Node* child = *iter; if(child->getTag() == ignoreTag){ iter++; }else{ iter++; this->operateallSchedulerAndActions(child,type,ignoreTag); } } } }}3,暂停
GamePauseUtils::getInstance()->operateallSchedulerAndActions(rootLayer,OPERATE_TYPE_PAUSE,IGnorE_TAG);4,恢复
GamePauseUtils::getInstance()->operateallSchedulerAndActions(rootLayer,OPERATE_TYPE_RESUME,IGnorE_TAG);总结
以上是内存溢出为你收集整理的cocos 3.2游戏暂停功能全部内容,希望文章能够帮你解决cocos 3.2游戏暂停功能所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)