cocos 3.2游戏暂停功能

cocos 3.2游戏暂停功能,第1张

概述1,GamePauseUtils.h //// GamePauseUtils.h// AdventureKing//// Created by jianan on 15/5/12.////#ifndef __AdventureKing__GamePauseUtils__#define __AdventureKing__GamePauseUtils__#include "

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游戏暂停功能所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1058173.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存