• cocos2D-X 常用功能封装


    Packaging_Kernel.h

    #pragma once
    #include <string>
    #include <map>
    #include <vector>
    #include "cocos2d.h"
    #include "uiCocosGUI.h"
    #include "SimpleAudioEngine.h"
    #include "cocostudioCocoStudio.h"
    #include "cocoseditor-supportspineSkeletonAnimation.h"
    #include "cocosplatformdesktopCCGLViewImpl-desktop.h"
    #include "cocosmathCCGeometry.h"
    #include "cocoseditor-supportspineextension.h"
    #include "cocosmathVec2.h"
    #include "cocos2d/extensions/GUI/CCScrollView/CCTableView.h"
    
    
    #include <iostream>
    #include <windows.h>
    #include <tchar.h>
    
    
    using namespace std;
    using namespace cocos2d;
    using namespace cocostudio;
    using namespace ui;
    using namespace spine;
    using namespace timeline;
    using namespace CocosDenshion;
    
    
    
    typedef struct MONITORBING
    {
        EventDispatcher *Dispatcher;
        EventListenerMouse *ListenerMouse;
    }MONITORBING, *LPMONITORBING;
    typedef struct POKERS
    {
        int PokerColor = 0;
        int CurState = 0;
        int Poker = 0;
    }Poker,*LPPoker;
    typedef struct USERS
    {
        int PokerColor = 0;
        int CurState = 0;
        int Poker = 0;
    }User,*LPUser;
    
    typedef struct TOUCH
    {
        int KeyState = 0; //按下 1,移动 2,抬起 3
        int KeyCode = 0;//保留
        int TouchMove = 0;
        int TouchEnd = 0;
        Vec2 CurPos = Vec2::ZERO;
        Vec2 LastPos = Vec2::ZERO;
    }RecvTouch,*LPRecvTouch;
    
    typedef struct COOR
    {
        int X;
        int Y;
    }Coor, Position;
    
    
    //LPMONITORBING LPMonitorBing = new MONITORBING;
    //LPMonitorBing->Dispatcher = Director::getInstance()->getEventDispatcher();
    //LPMonitorBing->ListenerMouse = EventListenerMouse::create();
    //LPMonitorBing->ListenerMouse->onMouseDown = CC_CALLBACK_1(HelloWorld::OnMouseDown, this);
    //LPMonitorBing->Dispatcher->addEventListenerWithSceneGraphPriority(LPMonitorBing->ListenerMouse, this);
    
    typedef void(*MOUSEEVENTFUNCTION)(Event*);
    typedef void(*KEYEVENTFUNCTION)(EventKeyboard::KeyCode, Event*);
    typedef bool(*TOUCHEVENTFUNCTION)(Touch*, Event*);
    typedef void(*TOUCHEVENT_FUNCTION)(Touch*, Event*);
    typedef void(*MENUITEMLABEL_FUNCTION)(Ref*);
    
    class PackagingClass
    {
        //精灵
        Sprite *m_Sprites = NULL;
        Vec2 *m_SpritesPosition = NULL;
        Vec2 *m_SpritesWidthAndHeight = NULL;
        //纹理
        Texture2D *m_Texture2D = NULL;
        //粒子
        //CCParticleExplosion        //爆炸粒子特效
        //    CCParticleFire                  //火焰粒子特效
        //    CCParticleFlower             //花束粒子特效
        //    CCParticleFireworks       //烟花粒子特效
        //    CCParticleGalaxy            //星系粒子特效
        //    CCParticleMeteor           //流星粒子特效
        //    CCParticleRain                //下雨粒子特效
        //    CCParticleSmoke            //烟雾粒子特效
        //    CCParticleSnow              //下雪粒子特效
        //    CCParticleSpiral              //漩涡粒子特效
        //    CCParticleSun                 //太阳粒子特效
        ParticleFireworks *m_ParticleEffects = NULL;
        //遮罩
        ClippingNode *m_MaskTier = NULL;//蒙版
        Vec2 *m_ButtonPosition = NULL;
        Vec2 *m_ButtonWidthAndHeight = NULL;
        //音频
        char m_MusicFile[256] = { 0 };
        //动作
        CallFunc *m_CallBackFunctionAction = NULL;//回调函数无参动作
        DelayTime *m_DelayAction = NULL;//延时动作
        Sequence *m_ConnectAction = NULL;//连接动作
        RepeatForever *m_InfiniteAction = NULL;//无限动作
    
        //
        std::map<std::string, Sprite*> m_MapSprite;//Map精灵
        std::map<std::string, Texture2D*> m_MapTexture;//Map纹理
        std::map<std::string, Button*> m_MapButton;//Map按钮
        std::map<std::string, SkeletonAnimation*> m_MapSkeletonAnimation;//Map骨骼动画
        std::map<Texture2D*, Sprite*> m_MapTextureSprite;//Map纹理精灵
    
    
        //单子弹
        std::vector<Sprite*> m_VectorBullet;//Vector子弹
        //单敌机
        std::vector<Sprite*> m_VectorEnemy;//Vector敌机
        //双管子弹
        std::vector<Sprite*> m_VectorBullet_One;//管子one
        std::vector<Sprite*> m_VectorBullet_Two;//管子two
    
    
        //Poker
        Poker m_Poker[54];//54张
        User m_UserLeft[20];
        User m_MainUser[20];//地主
        User m_UserRight[20];
    
        //五子棋
        static Vec2 m_StandardPos[11][11];
    
    
    public:
        PackagingClass();
        ~PackagingClass();
    
        //单子弹功能
        void Push_Back(Sprite *Sprites);
        void UpdataBullet_Y_(Node *This, float Max_Y, float Speed);//当前节点,最大的Y,速度
        void Delete_Bullet();//删除整个vector
        //停用,Look Function Interior
        void Delete_OneBullet(Node *This, std::vector<Sprite*>::iterator &it_);
        std::vector<Sprite*> *Get_Bullet_it();
        //单向基本的碰撞释放
        void Release_One_AirAndBulletCrash(Node *This);
        //敌机功能
        void EnemyDirPush_Back(Sprite *Sprites);
        void UpdataEnemyDir_Y_(Node *This,float X,float Y,float Max_Y,float Speed);
        void Delete_EnemyDir();//删除整个vector
        //停用,Look Function Interior
        void Delete_OneEnemy(Node *This, std::vector<Sprite*>::iterator &it_);
        std::vector<Sprite*> *Get_Enemy_it();
    
        //双管子弹
        void Push_Back(Sprite *Sprites_One,Sprite *Sprite_Two);
        void UpdataDoubleBullet_Y_(Node *This, float Max_Y, float Speed);//当前节点,最大的Y,速度
        void Delete_DoubleBullet();//删除整个vector
        std::vector<Sprite*> *Get_Bullet_itOne();
        std::vector<Sprite*> *Get_Bullet_itTwo();
        //双管子弹的碰撞释放
        void Release_Double_AirAndBulletCrash(Node *This);
    
    
        //poker 洗牌
        void InitShuffle();
        //发牌
        void Deal();
        //排序
        void User_Sort(User *MainUser, int Len);
        //加载牌牌
        void LoadPoker();
        //显示牌牌
        void ShowPoker(Node *This);
        //返回牌牌
        User *GetUserMainUser();
        User *GetUserLeft();
        User *GetUserRight();
        //出牌牌后牌牌位置更新,在出牌后把CurState改为1,及把牌返回
        void OutPokerPostionUpdata(User *Poker__,int Len,int Width,int W,int MainY, Node *This);//用处不是太大
        //加载左边玩家的牌牌
        void OutPokerLeftBackgroundUpdata(User *Poker_,int Len, Texture2D *Texture,Node *This);
        //加载右边玩家的牌牌
        void OutPokerRightBackgroundUpdata(User *Poker_, int Len, Texture2D *Texture, Node *This);
    
    
        //五子棋
        DrawNode* CreateGobangMap();
        //标准坐标
        static void StandardPos(Sprite *Sprites);
    
    
    
    
    
    
    
    
    
    
    
    
    
        //根据文件创建一个精灵
        Sprite* CreateSprite(const char *FileName, const Vec2 Position);
        Sprite* CreateSprite(const char *FileName);
        //根据文件获取一个精灵
        Sprite* GetSprite(const char *FileName);
        //根据文件获取精灵位置
        Vec2 GetSpritePosition(const char *FileName);
        //根据文件获取精灵宽高
        Size GetSpriteWidthAndHeight(const char *FileName);
        //根据文件创建一张纹理
        Texture2D* CreateTexture2D(const char *FileName);
        //根据文件获取一张纹理
        Texture2D* GetTexture(const char *FileName);
        //根据一张纹理创建一个精灵
        Sprite* CreateTextureSprite(Texture2D *Texture);
        //根据一张纹理获取一个纹理精灵
        Sprite* GetTextureSprite(Texture2D *Texture);
        //根据抬起图片获取按钮
        Button* GetButton(const char *FileName);
        //根据json文件获取一个骨骼动画
        SkeletonAnimation* GetSkeletonAnimation(const char *FileName);
    
        //创建遮罩层
        ClippingNode* CreateMaskTier(const char *Template_FilePathName,//模板路径
            Sprite *EffectsSprite,//特效精灵
            Vec2 Template_Position,//模板位置
            Vec2 Effects_Position);//特效精灵位置
        ClippingNode* CreateMaskTier(Sprite *Template_Sprite,//模板精灵
            Sprite *EffectsSprite,//特效精灵
            Vec2 Template_Position,//模板位置
            Vec2 Effects_Position);//特效精灵位置
    
        //创建按钮
        //注册事件加这一句
        //参数 Ref* ref, TouchEventType *event
        //->addTouchEventListener(this, toucheventselector(class::OnTouchButton));//虚函数
        Button *CreateButton(Node *node,
            const char *UpImageFileName,
            const char *DownImageFileName,
            const char *ProhibitImageFileName);
        Button *CreateButton(const char *UpImageFileName,
            const char *DownImageFileName,
            const char *ProhibitImageFileName);
    
        //创建一个ScrollView
        ScrollView *CreateScrollView();
        //创建一个Text
        Label *CreateText(string Text, string Font, float Size = 50);
    
        //加载csb动画(骨骼)
        Node* LoadCSBAnimation(const char *FilePathName, Vec2 Position, const float SizeScale, const float TimeSpeed, bool Bool);
        //加载 .json + .stlas 文件动画
        SkeletonAnimation* Load_jsonAndStlas_Animation(const char *FilePathName_Json, const char *FilePathName_Atlas, Vec2 Position, const float TimeSpeed, bool Bool, const char *JsonIndex);
        //加载 .plist + .png 帧动画
        Sprite* Load_PlistAndPng_Animation(const char *FilePathName, Vec2 Position, const int EndFrame, char *XmlImageName);
        //注册鼠标事件
        void RegisterMouseEvent(Node *node,//this
            MOUSEEVENTFUNCTION OnMouseDown,//成员函数必须是静态
            MOUSEEVENTFUNCTION OnMouseUp,//成员函数必须是静态
            MOUSEEVENTFUNCTION OnMouseMove,//成员函数必须是静态
            MOUSEEVENTFUNCTION OnMouseScroll);//成员函数必须是静态
        void RegisterMouseEvent(Node *node,
            MOUSEEVENTFUNCTION OnMouseDown,//成员函数必须是静态
            MOUSEEVENTFUNCTION OnMouseUp,//成员函数必须是静态
            MOUSEEVENTFUNCTION OnMouseMove);//成员函数必须是静态
        //注册按键事件
        void RegisterKeyEvent(Node *node,//this
            KEYEVENTFUNCTION KeyDown,//成员函数必须是静态
            KEYEVENTFUNCTION KeyUp);//成员函数必须是静态
        //注册触摸单点事件
        void RegisterTouchEvent(Node *node,
            TOUCHEVENTFUNCTION OnTouchBegin,//成员函数必须是静态
            TOUCHEVENT_FUNCTION OnTouchMove,//成员函数必须是静态
            TOUCHEVENT_FUNCTION OnTouchEnd);//成员函数必须是静态
        void RegisterTouchEvent(Node *node,
            TOUCHEVENTFUNCTION OnTouchBegin,//成员函数必须是静态
            TOUCHEVENT_FUNCTION OnTouchMove,//成员函数必须是静态
            TOUCHEVENT_FUNCTION OnTouchEnd,//成员函数必须是静态
            TOUCHEVENT_FUNCTION OnTouchCancelle);//成员函数必须是静态
    
        //播放音乐
        char *PlayBackgroundMusic(const char *BackgroundMusicName, bool Loop = true);
        //暂停音乐
        void PauseBackgroundMusic();
        //注册每一帧调用:void class::Update(float Time);
        static void RegisterEachFrameCall(Node *node);
        //开启控制台,最好放在Main函数里
        void OpenConsole();
        void OpenConsole2();
    
        //切换场景
        static void ChangeScene(Scene* scene);
    
        //触摸移动
        static void TouchMoveSprite(Touch *touch,Sprite* Sprites);
        static void TouchMoveSprite(Touch *touch, Sprite* Sprites,void *null);
    
    
        //Menu菜单
        Menu *CreateMenu();
        //用某个节点创建菜单项
        MenuItemLabel *InsertMenuItemLabel(Node *node);
        //注册菜单项回调
        void RegisterMenuItemLabel(MenuItemLabel* MenuItemLabel,
            MENUITEMLABEL_FUNCTION MenuItemCallback);//成员函数必须是静态
        //布局,注意是堆内存,用完后注意注意注意释放
        Position *OverallArrangemet(int Number);
    
    
    protected:
        //鼠标按下
        static void _OnMouseDown(MOUSEEVENTFUNCTION OnMouseDown, Event *event);
        //鼠标抬起
        static void _OnMouseUp(MOUSEEVENTFUNCTION OnMouseUp, Event *event);
        //鼠标移动
        static void _OnMouseMove(MOUSEEVENTFUNCTION OnMouseMove, Event *event);
        //鼠标滚轮
        static void _OnMouseScroll(MOUSEEVENTFUNCTION OnMouseScroll, Event *event);
        //按键按下
        static void _OnKeyPressed(KEYEVENTFUNCTION OKeyDown, EventKeyboard::KeyCode KeyCode, Event *event);
        //按键抬起
        static void _OnKeyReleased(KEYEVENTFUNCTION OKeyUp, EventKeyboard::KeyCode KeyCode, Event *event);
        //触摸开始
        static bool _OnTouchBegin(TOUCHEVENTFUNCTION OnTouchBegin, Touch *touch, Event *event);
        //触摸移动
        static void _OnTouchMove(TOUCHEVENT_FUNCTION OnTouchMove, Touch *touch, Event *event);
        //触摸结束
        static void _OnTouchEnd(TOUCHEVENT_FUNCTION OnTouchEnd, Touch *touch, Event *event);
        //触摸取消
        static void _OnTouchCancelle(TOUCHEVENT_FUNCTION OnTouchCancelle, Touch *touch, Event *event);
    private:
        BOOL InsertionSprite(std::string Name, Sprite *Sprites);
        BOOL InsertionTexture(std::string Name, Texture2D *Texture);
        BOOL InsertionButton(std::string Name,Button *button);
        BOOL InsertionSkeletonAnimation(std::string Name, SkeletonAnimation *Skeleton_Animation);
        BOOL InsertionTextureSprite(Texture2D *Texture,Sprite *Sprites);
    };
    //9宫格精灵
    //Scale9Sprite *S = Scale9Sprite::create("_9.png");
    //S->setPosition(Vec2((visibleSize / 2).width, (visibleSize / 2).height));
    //S->setCapInsets(CCRectMake(0,0,0,0));
    //S->setContentSize(Size::Size(800,600));
    //this->addChild(S);
    
    //自定义监听事件
    //Button *Btn = m_Obj->CreateButton(this, "ButtonFile/game_6.png", "ButtonFile/game_27.png", "ButtonFile/game_187.png");
    //Btn->addTouchEventListener(this, toucheventselector(HelloWorld::OnTouchButton));
    //auto listener = EventListenerCustom::create("Event",
    //    [](EventCustom*)
    //{
    //    CCLOG("===========>Event");
    //});
    //Director::getInstance()->getEventDispatcher()->addEventListenerWithFixedPriority(listener, 1);
    //Director::getInstance()->getEventDispatcher()->dispatchCustomEvent("Event");
    
    //多点触控
    //EventListenerTouchAllAtOnce *Listener = EventListenerTouchAllAtOnce::create();
    //Listener->onTouchesBegan = [=](const std::vector<Touch*>& touch, Event* event)
    //{
    //    CCLOG("Touches count %lu", touch.size());
    //    Touch *t;
    //    for (auto it = touch.begin(); it != touch.end(); it++)
    //    {
    //        t = *it;
    //        CCLOG("X = %f , Y = %f", t->getLocation().x, t->getLocation().y);
    //    }
    //};
    //Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(Listener, this);
    
    
    
    //==============================================成员函数调用约定
    #define Updata update(float Time)
    
    
    #define __BUTTONCLASS__(__CLASS__) 
    toucheventselector(__CLASS__::OnTouchButton)
    
    #define ONTOUCHBUTTON(__CLASS__)
    __CLASS__::OnTouchButton
    
    #define ONMOUSEDOWN(__CLASS__)
    __CLASS__::OnMouseDown
    
    #define ONMOUSEUP(__CLASS__)
    __CLASS__::OnMouseUp
    
    #define ONMOUSEMOVE(__CLASS__)
    __CLASS__::OnMouseMove
    
    #define ONMOUSESCROLL(__CLASS__)
    __CLASS__::OnMouseScroll
    
    #define ONTOUCHBEGIN(__CLASS__)
    __CLASS__::OnTouchBegin
    
    #define ONTOUCHMOVE(__CLASS__)
    __CLASS__::OnTouchMove
    
    #define ONTOUCHEND(__CLASS__)
    __CLASS__::OnTouchEnd
    
    #define ONTOUCHCANCELLE(__CLASS__)
    __CLASS__::OnTouchCancelle
    
    #define ONKEYPRESSED(__CLASS__)
    __CLASS__::OnKeyPressed
    
    #define ONKEYRELEASED(__CLASS__)
    __CLASS__::OnKeyReleased
    
    
    
    //static void OnMouseDown(Event *event);
    //static void OnMouseUp(Event *event);
    //static void OnMouseMove(Event *event);
    //
    //static void OnKeyPressed(EventKeyboard::KeyCode keycode, Event *event);
    //static void OnKeyReleased(EventKeyboard::KeyCode keycode, Event *event);
    //
    //static bool OnTouchBegin(Touch *touch, Event *event);
    //static void OnTouchMove(Touch *touch, Event *event);
    //static void OnTouchEnd(Touch *touch, Event *event);
    //static void OnTouchCancelle(Touch *touch, Event *event);
    //
    //void Main::OnMouseDown(Event *event)
    //{
    //    EventMouse *M = (EventMouse*)event;
    //
    //    CCLOG("MouseDown");
    //    m_State = 1;
    //}
    //void Main::OnMouseUp(Event *event)
    //{
    //    CCLOG("MouseUp");
    //}
    //void Main::OnMouseMove(Event *event)
    //{
    //    CCLOG("MouseMove");
    //}
    //
    //void Main::OnTouchButton(Ref* ref, TouchEventType *event)
    //{
    //          std::cout << ((Widget*)ref)->getTouchMovePosition().x << " " << ((Widget*)ref)->getTouchMovePosition().y<< std::endl;
    //    int var = 0;
    //}
    //
    //void Main::OnKeyPressed(EventKeyboard::KeyCode keycode, Event *event)
    //{
    //
    //    if (keycode == EventKeyboard::KeyCode::KEY_UP_ARROW)
    //    {
    //        CCLOG("KeyDown  %d", keycode);
    //    }
    //    if (keycode == EventKeyboard::KeyCode::KEY_DOWN_ARROW)
    //    {
    //        CCLOG("KeyDown  %d", keycode);
    //    }
    //    if (keycode == EventKeyboard::KeyCode::KEY_LEFT_ARROW)
    //    {
    //        CCLOG("KeyDown  %d", keycode);
    //    }
    //    if (keycode == EventKeyboard::KeyCode::KEY_RIGHT_ARROW)
    //    {
    //        CCLOG("KeyDown  %d", keycode);
    //
    //    }
    //
    //}
    //void Main::OnKeyReleased(EventKeyboard::KeyCode keycode, Event *event)
    //{
    //    CCLOG("KeyUp  %d", keycode);
    //}
    //
    //bool Main::OnTouchBegin(Touch *touch, Event *event)
    //{
    //    CCLOG("Touch %f,%f", touch->getLocation().x, touch->getLocation().y);
    //    CCLOG("OnTouchBegan");
    //    return true;
    //}
    //void Main::OnTouchMove(Touch *touch, Event *event)
    //{
    //    CCLOG("onTouchMoved");
    //}
    //void Main::OnTouchEnd(Touch *touch, Event *event)
    //{
    //    CCLOG("onTouchEnded");
    //}
    //void Main::OnTouchCancelle(Touch *touch, Event *event)
    //{
    //    CCLOG("OnTouchCancelled");
    //}
    //void Main::menuCloseCallback(Ref* pSender)
    //{
    //    Director::getInstance()->end();
    //    m_GameLogScene.EndGame_LogScene(this);
    //
    //#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    //    exit(0);
    //#endif
    //
    //}

    Packaging_Kernel.cpp

    #include "Packaging_Kernel.h"
    
    
    Vec2 PackagingClass::m_StandardPos[11][11] = { Vec2::ZERO };
    
    PackagingClass::PackagingClass()
    {
        srand(GetTickCount());
    }
    PackagingClass::~PackagingClass()
    {
        PackagingClass::Delete_Bullet();
        PackagingClass::Delete_EnemyDir();
        PackagingClass::Delete_DoubleBullet();
    }
    
    BOOL PackagingClass::InsertionSprite(std::string Name, Sprite *Sprites)
    {
        if (Sprites != NULL)
        {
            m_MapSprite.insert(std::pair<std::string, Sprite*>(Name, Sprites));
            return TRUE;
        }
        return FALSE;
    }
    BOOL PackagingClass::InsertionTexture(std::string Name, Texture2D *Texture)
    {
        if (Texture != NULL)
        {
            m_MapTexture.insert(std::pair<std::string, Texture2D*>(Name, Texture));
            return TRUE;
        }
        return FALSE;
    }
    BOOL PackagingClass::InsertionButton(std::string Name, Button *button)
    {
        if (button != NULL)
        {
            m_MapButton.insert(std::pair<std::string, Button*>(Name, button));
            return TRUE;
        }
        return FALSE;
    }
    BOOL PackagingClass::InsertionSkeletonAnimation(std::string Name, SkeletonAnimation *Skeleton_Animation)
    {
        if (Skeleton_Animation != NULL)
        {
            m_MapSkeletonAnimation.insert(std::pair<std::string, SkeletonAnimation*>(Name, Skeleton_Animation));
        }
        return FALSE;
    }
    BOOL PackagingClass::InsertionTextureSprite(Texture2D *Texture, Sprite *Sprites)
    {
        if (Texture != NULL && Sprites != NULL)
        {
            m_MapTextureSprite.insert(std::pair<Texture2D*, Sprite*>(Texture, Sprites));
            return TRUE;
        }
        return FALSE;
    }
    
    Sprite* PackagingClass::CreateSprite(const char *FileName, const Vec2 Position)
    {
        if (FileName != NULL)
        {
            m_Sprites = Sprite::create(FileName);
            m_Sprites->setPosition(Position);
            PackagingClass::InsertionSprite(FileName, m_Sprites);
            return m_Sprites;
        }
        return NULL;
    }
    Sprite* PackagingClass::CreateSprite(const char *FileName)
    {
        if (FileName != NULL)
        {
            m_Sprites = Sprite::create(FileName);
            m_Sprites->setPosition(Vec2::ZERO);
            PackagingClass::InsertionSprite(FileName, m_Sprites);
            return m_Sprites;
        }
        return NULL;
    }
    Sprite* PackagingClass::GetSprite(const char *FileName)
    {
        if (FileName != NULL)
        {
            if (m_MapSprite[FileName])
            {
                return m_MapSprite[FileName];
            }
        }
        return NULL;
    }
    Texture2D* PackagingClass::GetTexture(const char *FileName)
    {
        if (FileName != NULL)
        {
            if (m_MapTexture[FileName])
            {
                return m_MapTexture[FileName];
            }
        }
        return FALSE;
    }
    Vec2 PackagingClass::GetSpritePosition(const char *FileName)
    {
        if (FileName != NULL)
        {
            if (m_MapSprite[FileName])
            {
                return m_MapSprite[FileName]->getPosition();
            }
        }
        return Vec2::ZERO;
    }
    Size PackagingClass::GetSpriteWidthAndHeight(const char *FileName)
    {
        if (FileName != NULL)
        {
            if (m_MapSprite[FileName])
            {
                return m_MapSprite[FileName]->getContentSize();
            }
        }
        return Size::ZERO;
    }
    Texture2D* PackagingClass::CreateTexture2D(const char *FileName)
    {
        if (FileName != NULL)
        {
            m_Texture2D = TextureCache::getInstance()->addImage(FileName);
            if (m_Texture2D)
            {
                PackagingClass::InsertionTexture(FileName, m_Texture2D);
                return m_Texture2D;
            }
        }
        return NULL;
    }
    Sprite* PackagingClass::CreateTextureSprite(Texture2D *Texture)
    {
        if (Texture != NULL)
        {
            Sprite* Sprites = Sprite::createWithTexture(Texture);
            if (Sprites)
            {
                PackagingClass::InsertionTextureSprite(Texture, Sprites);
                Sprites->setPosition(Vec2::ZERO);
                return Sprites;
            }
        }
        return NULL;
    }
    Button* PackagingClass::GetButton(const char *FileName)
    {
        if (FileName != NULL)
        {
            if (m_MapButton[FileName])
            {
                return m_MapButton[FileName];
            }
        }
        return NULL;
    }
    SkeletonAnimation* PackagingClass::GetSkeletonAnimation(const char *FileName)
    {
        if (FileName != NULL)
        {
            if (m_MapSkeletonAnimation[FileName])
            {
                return m_MapSkeletonAnimation[FileName];
            }
        }
        return NULL;
    }
    Sprite* PackagingClass::GetTextureSprite(Texture2D *Texture)
    {
        if (Texture != NULL)
        {
            if (m_MapTextureSprite[Texture])
            {
                return m_MapTextureSprite[Texture];
            }
        }
        return NULL;
    }
    
    ClippingNode* PackagingClass::CreateMaskTier(const char *Template_FilePathName,
        Sprite *EffectsSprite,
        Vec2 Template_Position,
        Vec2 Effects_Position)
    {
        if (Template_FilePathName && EffectsSprite)
        {
            Sprite *Template = PackagingClass::CreateSprite(Template_FilePathName);
    
            Template->setPosition(Template_Position);
            EffectsSprite->setPosition(Effects_Position);
    
            ClippingNode *MaskTier = ClippingNode::create();
            MaskTier->setAlphaThreshold(0.5f);
            MaskTier->setInverted(false);
    
            MaskTier->addChild(EffectsSprite);
    
            MaskTier->setStencil(Template);
            m_MaskTier = MaskTier;
            return MaskTier;
        }
        return NULL;
    }
    ClippingNode* PackagingClass::CreateMaskTier(Sprite *Template_Sprite,//模板精灵
        Sprite *EffectsSprite,//特效精灵
        Vec2 Template_Position,//模板位置
        Vec2 Effects_Position)//特效精灵位置
    {
        if (Template_Sprite && EffectsSprite)
        {
    
            Template_Sprite->setPosition(Template_Position);
            EffectsSprite->setPosition(Effects_Position);
    
            ClippingNode *MaskTier = ClippingNode::create();
            MaskTier->setAlphaThreshold(0.5f);
            MaskTier->setInverted(false);
    
            MaskTier->addChild(EffectsSprite);
    
            MaskTier->setStencil(Template_Sprite);
            m_MaskTier = MaskTier;
            return MaskTier;
        }
        return NULL;
    }
    
    Node* PackagingClass::LoadCSBAnimation(const char *FilePathName,
        Vec2 Position,
        const  float SizeScale,
        const float TimeSpeed,
        bool IsLoop)
    {
        if (FilePathName != NULL)
        {
            Node *CSB = CSLoader::createNode(FilePathName);
            CSB->setPosition(Position);
            CSB->setScale(SizeScale);
    
            ActionTimeline *Action_Animation = CSLoader::createTimeline(FilePathName);
            Action_Animation->setTimeSpeed(TimeSpeed);
            CSB->runAction(Action_Animation);
            Action_Animation->gotoFrameAndPlay(0, IsLoop);
            return CSB;
        }
        return NULL;
    }
    
    SkeletonAnimation* PackagingClass::Load_jsonAndStlas_Animation(const char *FilePathName_Json,
        const char *FilePathName_Atlas,
        Vec2 Position, const float TimeSpeed,
        bool IsLoop, const char *JsonIndex)
    {
        if (FilePathName_Atlas != NULL && FilePathName_Json != NULL)
        {
            SkeletonAnimation *Skeleton_Animation = SkeletonAnimation::createWithFile(FilePathName_Json, FilePathName_Atlas);
            Skeleton_Animation->setPosition(Position);
            Skeleton_Animation->setTimeScale(TimeSpeed);
    
            Skeleton_Animation->setAnimation(0, JsonIndex, IsLoop);
            PackagingClass::InsertionSkeletonAnimation(FilePathName_Json, Skeleton_Animation);
            return Skeleton_Animation;
        }
    
        return NULL;
    }
    
    Sprite* PackagingClass::Load_PlistAndPng_Animation(const char *FilePathName,
        Vec2 Position,
        const int EndFrame,
        char *XmlImageName)
    {
        if (FilePathName != NULL && XmlImageName != NULL)
        {
            SpriteFrameCache *Sprite_Frame = SpriteFrameCache::getInstance();
            Sprite_Frame->addSpriteFramesWithFile(FilePathName);//"Animation\Plist.plist"
            char Name[64] = { 0 };
            Vector<SpriteFrame*> Vec;
            for (int i = 0; i < EndFrame; i++)
            {
                sprintf_s(Name, XmlImageName, i);//"image/boss_spider-angry_%d.png"
                Vec.pushBack(Sprite_Frame->getSpriteFrameByName(Name));
            }
            Animation *animation = Animation::createWithSpriteFrames(Vec, 0.1f);
            Animate *animate = Animate::create(animation);
            Sprite *sprite = Sprite::create();
            sprite->setPosition(Position);
            sprite->runAction(RepeatForever::create(animate));
            return sprite;
        }
        return NULL;
    }
    //播放音乐
    char *PackagingClass::PlayBackgroundMusic(const char *BackgroundMusicName, bool Loop)
    {
        if (BackgroundMusicName)
        {
            for (int i = 0; i < 256; i++)
            {
                if (!BackgroundMusicName[i])
                {
                    break;
                }
                m_MusicFile[i] = BackgroundMusicName[i];
            }
            SimpleAudioEngine::getInstance()->playBackgroundMusic(FileUtils::getInstance()->fullPathForFilename(m_MusicFile).c_str(), Loop);
            return m_MusicFile;
        }
        return NULL;
    }
    void PackagingClass::PauseBackgroundMusic()
    {
        SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
    }
    //创建按钮
    Button *PackagingClass::CreateButton(Node *node,
        const char *UpImageFileName,
        const char *DownImageFileName,
        const char *ProhibitImageFileName)
    {
        //注册事件加这一句
        //参数 Ref* ref, TouchEventType *event
        //->addTouchEventListener(this, toucheventselector(class::OnTouchButton));//虚函数
        Button *Buttons = Button::create();
        Buttons->loadTextureNormal(UpImageFileName);
        Buttons->loadTexturePressed(DownImageFileName);
        Buttons->loadTextureDisabled(ProhibitImageFileName);
        Buttons->setPosition(Vec2::ZERO);
        //此方法为无参的回调
        //Buttons->addClickEventListener();
        node->addChild(Buttons);
        PackagingClass::InsertionButton(UpImageFileName, Buttons);
        return Buttons;
    }
    Button *PackagingClass::CreateButton(const char *UpImageFileName,
        const char *DownImageFileName,
        const char *ProhibitImageFileName)
    {
        //注册事件加这一句
        //参数 Ref* ref, TouchEventType *event
        //->addTouchEventListener(this, toucheventselector(class::OnTouchButton));//虚函数
        Button *Buttons = Button::create();
        Buttons->loadTextureNormal(UpImageFileName);
        Buttons->loadTexturePressed(DownImageFileName);
        Buttons->loadTextureDisabled(ProhibitImageFileName);
        Buttons->setPosition(Vec2::ZERO);
        //此方法为无参的回调
        //Buttons->addClickEventListener();
        PackagingClass::InsertionButton(UpImageFileName, Buttons);
        return Buttons;
    }
    
    
    //开启控制台
    void PackagingClass::OpenConsole()
    {
    #ifdef WIN32
        _tsetlocale(LC_ALL, _T(" "));
        ::AllocConsole();
        ::freopen("CONIN$", "r", stdin);
        ::freopen("CONOUT$", "w", stdout);
        ::freopen("CONOUT$", "w", stderr);
    #endif // WIN32
    }
    void PackagingClass::OpenConsole2()
    {
    #ifdef WIN32
        ::AllocConsole();
        ::freopen("CONIN$", "r", stdin);
        ::freopen("CONOUT$", "w", stdout);
        ::freopen("CONOUT$", "w", stderr);
    #endif // WIN32
    }
    
    //创建一个ScrollView
    ScrollView *PackagingClass::CreateScrollView()
    {
        ScrollView *ScrollViews = ScrollView::create();
        //开启触摸
        ScrollViews->setTouchEnabled(true);
        //开启反弹
        ScrollViews->setBounceEnabled(true);
        //设置为垂直滚动
        ScrollViews->setDirection(ScrollView::Direction::VERTICAL);
        //设置显示的大小
        ScrollViews->setContentSize(Size(200, 500));
        //设置滚动容器的大小
        ScrollViews->setInnerContainerSize(Size(200, 100));
        //设置滚动条颜色
        ScrollViews->setScrollBarColor(Color3B::BLUE);
        //设置位置
        ScrollViews->setPosition(Vec2(200, 0));
        //设置是否开启滚动惯性
        ScrollViews->setInertiaScrollEnabled(true);
    
        //void setBounceEnabled(bool enabled)
        //    设置当滚动到边界时,是否内部容器发生弹回(bounce)效果
    
        //    bool isBounceEnabled() const
        //    获取边界弹回(bounce)状态。
    
        //    void setInertiaScrollEnabled(bool enabled)
        //    设置是否开启滚动惯性。
    
        //    bool isInertiaScrollEnabled() const
        //    获取滚动视图是否开启滚动惯性。
    
        //    void setScrollBarEnabled(bool enabled)
        //    设置是否启用滚动条。
    
        //    bool isScrollBarEnabled() const
        //    返回滚动条是否启用。
    
        //    virtual void setDirection(Direction dir)
        //    改变滚动视图的方向。
    
        //    Direction getDirection() const
        //    获取滚动视图的滚动方向。
    
        //    Layout * getInnerContainer() const
        //    获取滚动视图的内部布局容器,该布局容器为滚动视图的子节点。
    
        //    //与滚动方位有关
        //    void scrollToPercentVertical(float percent, float second, bool attenuated)
        //    按百分比竖直滚动内部布局容器
    
        //    void scrollToPercentHorizontal(float percent, float second, bool attenuated)
        //    按百分比水平滚动内部布局容器
    
        //    void scrollToPercentBothDirection(const Vec2 &percent, float second, bool attenuated)
        //    在竖直方向和水平方向分别按一定的百分比滚动内部布局容器
    
        //    void scrollToBottom(float second, bool attenuated)
        //    将内部的布局容器滚动到滚动视图的底部边界。
    
        //    void scrollToTop(float second, bool attenuated)
        //    将内部布局容器滚动到滚动视图的顶部边界。
    
        //    void scrollToLeft(float second, bool attenuated)
        //    将内部容器滚动到滚动视图的左端边界
    
        //    void scrollToRight(float time, bool attenuated)
        //    将内部布局容器滚动到滚动视图的右端边界
    
        //    void scrollToTopLeft(float second, bool attenuated)
        //    滚动内部布局容器到滚动视图的左上角
    
        //    void scrollToTopRight(float time, bool attenuated)
        //    滚动内部布局容器到滚动使徒的右上角
    
        //    void scrollToBottomLeft(float second, bool attenuated)
        //    滚动内部布局容器到视图的左下角
    
        //    void scrollToBottomRight(float time, bool attenuated)
        //    滚动内部布局容器到视图的右下角
    
        //    //与滚动条样式有关
        //    void setScrollBarPositionFromCorner(const Vec2 &positionFromCorner)
        //    设置滚动条水平位置和垂直位置。
    
        //    void setScrollBarPositionFromCornerForVertical(const Vec2 &positionFromCorner)
        //    设置滚动条垂直位置。
    
        //    Vec2 getScrollBarPositionFromCornerForVertical() const
        //    获得滚动条垂直位置。
    
        //    void setScrollBarPositionFromCornerForHorizontal(const Vec2 &positionFromCorner)
        //    设置滚动条水平位置。
    
        //    Vec2 getScrollBarPositionFromCornerForHorizontal() const
        //    获得滚动条水平位置。
    
        //    void setScrollBarWidth(float width)
        //    设置滚动条宽度。
    
        //    float getScrollBarWidth() const
        //    获取滚动条宽度。
    
        //    void setScrollBarColor(const Color3B &color)
        //    设置滚动条颜色。
    
        //    const Color3B & getScrollBarColor() const
        //    获取滚动条颜色。
    
        //    void setScrollBarOpacity(GLubyte opacity)
        //    设置滚动条透明度。
    
        //    GLubyte getScrollBarOpacity() const
        //    获取滚动条透明度。
    
        //    void setScrollBarAutoHideEnabled(bool autoHideEnabled)
        //    设置滚动条自动隐藏状态。
    
        //    bool isScrollBarAutoHideEnabled() const
        //    获取滚动条是否自动隐藏。
    
        //    void setScrollBarAutoHideTime(float autoHideTime)
        //    设置滚动条自动隐藏时间。
    
        //    float getScrollBarAutoHideTime() const
        //    获取滚动条是否自动隐藏。
    
        //    //
        //    void jumpToBottom()
        //    将内部布局容器移至视图底端。
    
        //    void jumpToTop()
        //    将内部布局容器移至视图顶端。
    
        //    void jumpToLeft()
        //    将内部布局容器移至视图左端。
    
        //    void jumpToRight()
        //    将内部布局容器移至视图右端。
    
        //    void jumpToTopLeft()
        //    将内部布局容器移至视图的左上角。
    
        //    void jumpToTopRight()
        //    将内部布局容器移至视图的右上角。
    
        //    void jumpToBottomLeft()
        //    将内部布局容器移至视图的左下角。
    
        //    void jumpToBottomRight()
        //    将内部布局容器移至视图的右下角。
    
        //    void jumpToPercentVertical(float percent)
        //    按一定的百分比竖直滚动视图内的布局容器。
    
        //    void jumpToPercentHorizontal(float percent)
        //    按一定的百分比竖直滚动视图内的布局容器。
    
        //    void jumpToPercentBothDirection(const Vec2 &percent)
        //    竖直方向和水平方向分别按一定的百分比滚动容器。
    
        //    void setInnerContainerSize(const Size &size)
        //    设置滚动容器的滚动区域大小。
    
        //    const Size & getInnerContainerSize() const
        //    获取滚动容器的滚动区域大小。
    
        //    void setInnerContainerPosition(const Vec2 &pos)
        //    设置容器内的位置。
    
        //    const Vec2 getInnerContainerPosition() const
        //    获取容器内的位置。
    
        //    void addEventListenerScrollView(Ref *target, SEL_ScrollViewEvent selector)
        //    添加一个回调函数,该回调函数将会在视图发生滚动时触发。
    
        //    virtual void addEventListener(const ccScrollViewCallback &callback)
        //    添加一个回调函数,该回调函数将在滚动事件触发时被调用。
    
        return ScrollViews;
    }
    //创建一个Text
    Label *PackagingClass::CreateText(string Text, string Font, float Size)
    {
        //暂时的两种方法
        Label *Labels = Label::createWithTTF(Text, Font, Size);
        //Label *Labels = Label::createWithSystemFont(Text,Font, 30);
        Labels->setPosition(Vec2(0, 0));
        Labels->setColor(Color3B::YELLOW);
        return Labels;
    }
    
    //切换场景
    void PackagingClass::ChangeScene(Scene* scene)
    {
        Director::getInstance()->replaceScene(TransitionPageTurn::create(2, scene, false));
    
        //    CCTransitionJumpZoom
        //    作用: 创建一个跳动的过渡动画
        //    参数1:过渡动作的时间
        //    参数2:切换到目标场景的对象
        //    reScene = CCTransitionJumpZoom ::create(t , s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionProgressRadialCCW
        //    作用: 创建一个扇形条形式的过渡动画, 逆时针方向
        //    参数1:过渡动作的时间
        //    参数2:切换到目标场景的对象
        //    reScene = CCTransitionProgressRadialCCW::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionProgressRadialCW
        //    作用: 创建一个扇形条形式的过渡动画, 顺时针方向
        //    参数1:过渡动作的时间
        //    参数2:切换到目标场景的对象
        //    reScene = CCTransitionProgressRadialCW::create(t,s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionProgressHorizontal
        //    作用: 创建一个水平条形式的过渡动画,  
        //    参数1:过渡动作的时间
        //    参数2:切换到目标场景的对象
        //    reScene = CCTransitionProgressHorizontal ::create(t,s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionProgressVertical
        //    作用: 创建一个垂直条形式的过渡动画,
        //    参数1:过渡动作的时间
        //    参数2:切换到目标场景的对象
        //    reScene = CCTransitionProgressVertical::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
    
        //    CCTransitionProgressInOut
        //    作用: 创建一个由里向外扩展的过渡动画,
        //    参数1:过渡动作的时间
        //    参数2:切换到目标场景的对象
        //    reScene = CCTransitionProgressInOut::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionProgressOutIn
        //    作用: 创建一个由外向里扩展的过渡动画,
        //    参数1:过渡动作的时间
        //    参数2:切换到目标场景的对象
        //    reScene = CCTransitionProgressOutIn::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionCrossFade
        //    作用:创建一个逐渐透明的过渡动画
        //    参数1:过渡动作的时间
        //    参数2:切换到目标场景的对象
        //    reScene = CCTransitionCrossFade::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionPageTurn
        //    作用:创建一个翻页的过渡动画
        //    参数1:过渡动作持续的时间
        //    参数2:切换的目标场景的对象
        //    参数3:是否逆向翻页
        //    reScene = CCTransitionPageTurn::create(t, s, false);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionFadeTR
        //    作用:创建一个部落格过渡动画, 从左下到右上
        //    参数1:过渡动作持续的时间
        //    参数2:切换的目标场景的对象
        //    reScene =CCTransitionFadeTR::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionFadeBL
        //    作用:创建一个部落格过渡动画, 从右上到左下
        //    参数1:过渡动作持续的时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionFadeBL::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionFadeUp
        //    作用:创建一个从下到上,条形折叠的过渡动画
        //    参数1:过渡动作持续的时间
        //    参数2:切换的目标场景的对象
        //    reScene= CCTransitionFadeUp::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(s);
    
        //    CCTransitionFadeDown
        //    作用:创建一个从上到下,条形折叠的过渡动画
        //    参数1:过渡动作持续的时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionFadeDown::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionTurnOffTiles
        //    作用:创建一个随机方格消失的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene= CCTransitionTurnOffTiles::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionSplitRows
        //    作用:创建一个分行划分切换的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionSplitRows::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionSplitCols
        //    作用:创建一个分列划分切换的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionSplitCols::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionFade
        //    作用:创建一个逐渐过渡到目标颜色的切换动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    参数3:目标颜色
        //    reScene= CCTransitionFade::create(t, s, ccc3(255, 0, 0));
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionFlipX
        //    作用:创建一个x轴反转的切换动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    参数3:反转类型的枚举变量   左右上下
        //    kOrientationDownOver kOrientationLeftOver kOrientationRightOver  kOrientationUpOver
        //    reScene  = CCTransitionFlipX::create(t, s, kOrientationRightOver);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionFlipY
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    参数3:反转类型的枚举变量   左右上下
        //    reScene = CCTransitionFlipY::create(t, s
        //                                        , kOrientationDownOver);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionFlipAngular
        //    作用:创建一个带有反转角切换动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    参数3:反转类型的枚举变量   左右上下
        //    reScene = CCTransitionFlipAngular::create(t, s, kOrientationLeftOver);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionZoomFlipX
        //    作用:创建一个带有缩放的x轴反转切换的动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    参数3:反转类型的枚举变量   左右上下
        //    reScene=CCTransitionZoomFlipX::create(t, s, kOrientationLeftOver);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionZoomFlipY
        //    作用:创建一个带有缩放的Y轴反转切换的动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    参数3:反转类型的枚举变量   左右上下
        //    reScene=CCTransitionZoomFlipY::create(t, s, kOrientationDownOver);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionZoomFlipAngular
        //    作用:创建一个带有缩放 ,反转角切换的动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    参数3:反转类型的枚举变量   左右上下
        //    reScene=CCTransitionZoomFlipAngular::create(t, s, kOrientationRightOver);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionShrinkGrow
        //    创建一个放缩交替的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionShrinkGrow::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionRotoZoom
        //    创建一个旋转放缩交替的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionRotoZoom::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionMoveInL
        //    作用:创建一个从左边推入覆盖的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionMoveInL::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionMoveInR
        //    作用:创建一个从右边推入覆盖的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionMoveInR::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionMoveInB
        //    作用:创建一个从下边推入覆盖的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionMoveInB::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionMoveInT
        //    作用:创建一个从上边推入覆盖的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene = CCTransitionMoveInT::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionSlideInL
        //    作用:创建一个从左侧推入并顶出旧场景的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象    
        //    reScene  =CCTransitionSlideInL::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionSlideInR
        //    作用:创建一个从右侧推入并顶出旧场景的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene  =CCTransitionSlideInR::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionSlideInT
        //    作用:创建一个从顶部推入并顶出旧场景的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //    reScene  =CCTransitionSlideInT::create(t, s);
        //    CCDirector::sharedDirector()->replaceScene(reScene);
    
        //    CCTransitionSlideInB
        //    作用:创建一个从下部推入并顶出旧场景的过渡动画
        //    参数1:过渡动作的持续时间
        //    参数2:切换的目标场景的对象
        //reScene = CCTransitionSlideInB::create(t, s);
        //CCDirector::sharedDirector()->replaceScene(reScene);
    }
    
    //触摸移动
    void PackagingClass::TouchMoveSprite(Touch *touch, Sprite* Sprites)
    {
        Vec2 Temp = touch->getLocation() - touch->getPreviousLocation();//当前的点减上次的点
        //Sprites->setPosition(Vec2(Sprites->getPosition().x, Sprites->getPosition().y + Temp.y));
        //Sprites->setPosition(Vec2(Sprites->getPosition().x + Temp.x, Sprites->getPosition().y));
        Sprites->setPosition(Vec2(Sprites->getPosition().x + Temp.x, Sprites->getPosition().y + Temp.y));
    }
    void PackagingClass::TouchMoveSprite(Touch *touch, Sprite* Sprites, void *null)
    {
        Vec2 Temp = touch->getLocation() - touch->getPreviousLocation();//当前的点减上次的点
        Sprites->setPosition(Vec2(Sprites->getPosition().x + Temp.x, Sprites->getPosition().y + Temp.y));
        for (int i = 0; i < 11; i++)
        {
            for (int j = 0; j < 11; j++)
            {
                if (Sprites->getPosition().x >= m_StandardPos[i][j].x - 25.0f && Sprites->getPosition().x <= m_StandardPos[i][j].x + 25.0f &&
                    Sprites->getPosition().y >= m_StandardPos[i][j].y - 25.0f && Sprites->getPosition().y <= m_StandardPos[i][j].y + 25.0f)
                {
                    Sprites->setPosition(m_StandardPos[i][j]);
                    return;
                }
            }
        }
    
    }
    
    
    //Menu菜单
    Menu *PackagingClass::CreateMenu()
    {
        Menu *menu = Menu::create();
        return menu;
    }
    //用某个节点创建菜单项
    MenuItemLabel *PackagingClass::InsertMenuItemLabel(Node *node)
    {
        MenuItemLabel *menuItemLabel = MenuItemLabel::create(node);
        //menuItemLabel->setPosition(Vec2(0, 0));
        //menuItemLabel->setName("123");
        //menuItemLabel->setTag(666);
        return menuItemLabel;
    }
    void PackagingClass::RegisterMenuItemLabel(MenuItemLabel* MenuItemLabel, MENUITEMLABEL_FUNCTION MenuItemCallback)
    {
        MenuItemLabel->setCallback(MenuItemCallback);
    
    
    
        //注册方法2
        //MenuItemLabel *menuItemLabel = MenuItemLabel::create(label, CC_CALLBACK_1(GameLogScene::MenuCallback, this));
    
        //menuItemLabel->setCallback(CC_CALLBACK_1(GameLogScene::MenuCallback, this));
    }
    //布局
    Position *PackagingClass::OverallArrangemet(int Number)
    {
        Position *Arr = new Position[Number];
        memset(Arr, 0, sizeof(Position) * Number);
        for (int i = 0; i < Number; i++)
        {
            Arr[i].X = 0;
            Arr[i].Y = 0;
            std::cout << Arr[i].X << " " << Arr[i].Y << std::endl;
        }
    
        //死的
        int Up_Y = 1240;
        int Down_Y = 280;
        //活的
        int DisPlayWidth = 750;
        int DIsplayHeight = 1335;
    
        //可调
        int Up_YOffset = 100;
        int Down_YOffset = 100;
    
        //求得
        int Up_Down_AddOffset = 0;
        Up_Down_AddOffset = Up_Y - (Down_Y + (Up_YOffset + Down_YOffset));
    
    
        //活的
        int DisPlayLeftX = 60;
        int DisPlayRightX = 690;
    
    
    
    
        //最上面的和最下面的的可放总位置的长度
        int RightUp = Up_Y - Up_YOffset;
        int RightDown = Down_Y + Down_YOffset;
        int RightUpAddDown = RightUp - RightDown;
    
        //偶数刚刚好
        if (Number % 2 == 0)
        {
            //中间那一个
            int Center = (Number / 2) + 1;
            //右边放的总个数
            //减去最上面的一个就是右边可以放的总数
            int RightCount = Center - 2;
            //右边可以放
            if (RightCount != 0)
            {
                //直接放的顶端
                Arr[0].X = DisPlayWidth / 2;
                Arr[0].Y = Up_Y;
                //人数为四个的时候
                if (RightCount == 1)
                {
                    Arr[1].X = DisPlayRightX;
                    Arr[1].Y = RightUp - RightUpAddDown / 2;
                    Arr[Center - 1].X = DisPlayWidth / 2;
                    Arr[Center - 1].Y = Down_Y;
                    Arr[3].X = DisPlayLeftX;
                    Arr[3].Y = RightUp - RightUpAddDown / 2;
                }
                else//人数大于四个的时候
                {
                    //Right
                    int RightOneByOneOffset = RightUpAddDown / (RightCount - 1);
                    for (int i = 0; i < RightCount; i++)
                    {
                        Arr[i + 1].X = DisPlayRightX;
                        Arr[i + 1].Y = RightUp;
                        RightUp -= RightOneByOneOffset;
                    }
                    Arr[Center - 1].X = DisPlayWidth / 2;
                    Arr[Center - 1].Y = Down_Y;
                    //Left
                    int temp = 2;
                    for (int i = Center; i < Number; i++)
                    {
                        Arr[i].X = DisPlayLeftX;
                        Arr[i].Y = Arr[i - temp].Y;
                        temp += 2;
                    }
                }
            }
            else
            {
                Arr[0].X = DisPlayWidth / 2;
                Arr[0].Y = Up_Y;
                Arr[Center - 1].X = DisPlayWidth / 2;
                Arr[Center - 1].Y = Down_Y;
            }
            for (int i = 0; i < Number; i++)
            {
                std::cout << Arr[i].X << " " << Arr[i].Y << std::endl;
            }
    
        }
        else
        {
            //中间那一个
            int Center = (Number + 1) / 2;
            //总数只有三个时,从右边开始只放一个
            if (Center - 1 == 1)
            {
                Arr[0].X = DisPlayRightX;
                Arr[0].Y = RightUp - RightUpAddDown / 2;
                Arr[1].X = DisPlayWidth / 2;
                Arr[1].Y = Down_Y;
                Arr[2].X = DisPlayLeftX;
                Arr[2].Y = Arr[0].Y;
            }
            else
            {
                Arr[Center - 1].X = DisPlayWidth / 2;
                Arr[Center - 1].Y = Down_Y;
                int SideCount = (Number - 1) / 2;
                int RightOneByOneOffset = RightUpAddDown / (SideCount - 1);
                for (int i = 0; i < Center - 1; i++)
                {
                    Arr[i].X = DisPlayRightX;
                    Arr[i].Y = RightUp;
                    RightUp -= RightOneByOneOffset;
                }
                //Left
                int temp = 2;
                for (int i = Center; i < Number; i++)
                {
                    Arr[i].X = DisPlayLeftX;
                    Arr[i].Y = Arr[i - temp].Y;
                    temp += 2;
                }
            }
    
        }
        return Arr;
    }
    
    
    
    
    
    
    
    
    
    //单子弹功能
    void PackagingClass::Push_Back(Sprite *Sprites)
    {
        m_VectorBullet.push_back(Sprites);
    }
    void PackagingClass::UpdataBullet_Y_(Node *This, float Max_Y, float Speed)//当前节点,最大的Y,速度
    {
        for (std::vector<Sprite*>::iterator it = m_VectorBullet.begin(); it != m_VectorBullet.end();)
        {
            if (!m_VectorBullet.empty())
            {
                (*it)->setPosition(Vec2((*it)->getPosition().x, (*it)->getPosition().y + Speed));
                if ((*it)->getPosition().y >= Max_Y)
                {
                    This->removeChild(*it);
                    it = m_VectorBullet.erase(it);
                }
                else//这里和放到end()后面有点区别"及在释放范围条件外不会出现断言"
                {
                    it++;
                }
            }
        }
    }
    void PackagingClass::Delete_Bullet()
    {
        m_VectorBullet.clear();
    }
    void PackagingClass::Delete_OneBullet(Node *This, std::vector<Sprite*>::iterator &it_)
    {
        //this->removeChild((*it_));
        //it_ = (*m_Obj->Return_Enemy_it()).erase(it_);
        //循环遍历时,在判断语句中加入这句,it++不变,就在end();的后面就是,不用else
    
        //std::vector<Sprite*>::iterator it_ 和std::vector<Sprite*> it 是不一样的,
    }
    std::vector<Sprite*> *PackagingClass::Get_Bullet_it()
    {
        return &m_VectorBullet;
    }
    
    //单向基本的碰撞释放
    void PackagingClass::Release_One_AirAndBulletCrash(Node *This)
    {
        bool CrashState = false;
        for (std::vector<Sprite*>::iterator it = m_VectorBullet.begin(); it != m_VectorBullet.end();)
        {
            for (std::vector<Sprite*>::iterator it_ = m_VectorEnemy.begin(); it_ != m_VectorEnemy.end();)
            {
                if ((*it_)->boundingBox().intersectsRect((*it)->boundingBox()))
                {
                    This->removeChild((*it_));
                    it_ = m_VectorEnemy.erase(it_);
                    CrashState = true;
                    break;
                }
                else
                {
                    it_++;
                }
            }
            if (CrashState)
            {
                This->removeChild((*it));
                it = m_VectorBullet.erase(it);
                CrashState = false;
            }
            else
            {
                it++;
            }
        }
    }
    
    //================================================================共同的敌机功能
    void PackagingClass::EnemyDirPush_Back(Sprite *Sprites)
    {
        m_VectorEnemy.push_back(Sprites);
    }
    void PackagingClass::UpdataEnemyDir_Y_(Node *This, float X, float Y, float Max_Y, float Speed)
    {
        for (std::vector<Sprite*>::iterator it = m_VectorEnemy.begin(); it != m_VectorEnemy.end();)
        {
            if (!m_VectorEnemy.empty())
            {
                (*it)->setPosition(Vec2((*it)->getPosition().x, (*it)->getPosition().y - Speed));
                if ((*it)->getPosition().y <= Max_Y)
                {
                    This->removeChild(*it);
                    it = m_VectorEnemy.erase(it);
                }
                else//这里和放到end()后面有点区别"及在释放范围条件外不会出现断言"
                {
                    it++;
                }
            }
        }
    }
    void PackagingClass::Delete_EnemyDir()
    {
        m_VectorEnemy.clear();
    }
    void PackagingClass::Delete_OneEnemy(Node *This, std::vector<Sprite*>::iterator &it_)
    {
        //this->removeChild((*it_));
        //it_ = (*m_Obj->Return_Enemy_it()).erase(it_);
        //循环遍历时,在判断语句中加入这句,it++不变,就在end();的后面就是,最好用else"及在释放范围外不会出现断言"
    }
    std::vector<Sprite*> *PackagingClass::Get_Enemy_it()
    {
        return &m_VectorEnemy;
    }
    
    
    //双管子弹
    void PackagingClass::Push_Back(Sprite *Sprites_One, Sprite *Sprite_Two)
    {
        assert(Sprites_One);
        assert(Sprite_Two);
        m_VectorBullet_One.push_back(Sprites_One);
        m_VectorBullet_Two.push_back(Sprite_Two);
    }
    void PackagingClass::UpdataDoubleBullet_Y_(Node *This, float Max_Y, float Speed)//当前节点,最大的Y,速度
    {
        for (std::vector<Sprite*>::iterator it = m_VectorBullet_One.begin(); it != m_VectorBullet_One.end();)
        {
            if (!m_VectorBullet_One.empty())
            {
                (*it)->setPosition(Vec2((*it)->getPosition().x, (*it)->getPosition().y + Speed));
                if ((*it)->getPosition().y >= Max_Y)
                {
                    This->removeChild(*it);
                    it = m_VectorBullet_One.erase(it);
                }
                else//这里和放到end()后面有点区别"及在释放范围条件外不会出现断言"
                {
                    it++;
                }
            }
        }
        for (std::vector<Sprite*>::iterator it = m_VectorBullet_Two.begin(); it != m_VectorBullet_Two.end();)
        {
            if (!m_VectorBullet_Two.empty())
            {
                (*it)->setPosition(Vec2((*it)->getPosition().x, (*it)->getPosition().y + Speed));
                if ((*it)->getPosition().y >= Max_Y)
                {
                    This->removeChild(*it);
                    it = m_VectorBullet_Two.erase(it);
                }
                else//这里和放到end()后面有点区别"及在释放范围条件外不会出现断言"
                {
                    it++;
                }
            }
        }
    }
    void PackagingClass::Delete_DoubleBullet()//删除整个vector
    {
        m_VectorBullet_One.clear();
        m_VectorBullet_Two.clear();
    }
    std::vector<Sprite*> *PackagingClass::Get_Bullet_itOne()
    {
        return &m_VectorBullet_One;
    }
    std::vector<Sprite*> *PackagingClass::Get_Bullet_itTwo()
    {
        return &m_VectorBullet_Two;
    }
    //双管子弹的碰撞释放
    void PackagingClass::Release_Double_AirAndBulletCrash(Node *This)
    {
        bool CrashState = false;
        for (std::vector<Sprite*>::iterator it = m_VectorBullet_One.begin(); it != m_VectorBullet_One.end();)
        {
            for (std::vector<Sprite*>::iterator it_ = m_VectorEnemy.begin(); it_ != m_VectorEnemy.end();)
            {
                if ((*it_)->boundingBox().intersectsRect((*it)->boundingBox()))
                {
                    This->removeChild((*it_));
                    it_ = m_VectorEnemy.erase(it_);
                    CrashState = true;
                    break;
                }
                else
                {
                    it_++;
                }
            }
            if (CrashState)
            {
                This->removeChild((*it));
                it = m_VectorBullet_One.erase(it);
                CrashState = false;
            }
            else
            {
                it++;
            }
        }
    
        bool CrashStates = false;
        for (std::vector<Sprite*>::iterator it = m_VectorBullet_Two.begin(); it != m_VectorBullet_Two.end();)
        {
            for (std::vector<Sprite*>::iterator it_ = m_VectorEnemy.begin(); it_ != m_VectorEnemy.end();)
            {
                if ((*it_)->boundingBox().intersectsRect((*it)->boundingBox()))
                {
                    This->removeChild((*it_));
                    it_ = m_VectorEnemy.erase(it_);
                    CrashStates = true;
                    break;
                }
                else
                {
                    it_++;
                }
            }
            if (CrashStates)
            {
                This->removeChild((*it));
                it = m_VectorBullet_Two.erase(it);
                CrashStates = false;
            }
            else
            {
                it++;
            }
        }
    }
    
    
    
    //poker 洗牌
    void PackagingClass::InitShuffle()
    {
        srand(GetTickCount());
        //
        m_Poker[52].PokerColor = 1;//小王
        m_Poker[52].CurState = 1;
        m_Poker[52].Poker = 15;
        m_Poker[53].PokerColor = 2;//大王
        m_Poker[53].CurState = 1;
        m_Poker[53].Poker = 15;
    
        int Color = 1;
        int Temp = 0;
    
        for (int i = 0; i < 52; i += 4)
        {
            Color = 1;
            for (int j = 0; j < 4; j++)
            {
                m_Poker[i + j].Poker = Temp + 2;
                m_Poker[i + j].CurState = 1;
                m_Poker[i + j].PokerColor = Color;
                Color++;
            }
            Temp++;
        }
    }
    //发牌
    void PackagingClass::Deal()
    {
        int TempRand = 0;
        for (int i = 0; i < 17; i++)
        {
            do
            {
                TempRand = rand() % 54;
                if (m_Poker[TempRand].CurState == 1)
                {
                    m_UserLeft[i].PokerColor = m_Poker[TempRand].PokerColor;
                    m_UserLeft[i].Poker = m_Poker[TempRand].Poker;
                }
            } while (m_Poker[TempRand].CurState == 0);
            m_Poker[TempRand].CurState = 0;
        }
        TempRand = 0;
        for (int i = 0; i < 17; i++)
        {
            do
            {
                TempRand = rand() % 54;
                if (m_Poker[TempRand].CurState == 1)
                {
                    m_MainUser[i].PokerColor = m_Poker[TempRand].PokerColor;
                    m_MainUser[i].Poker = m_Poker[TempRand].Poker;
                }
            } while (m_Poker[TempRand].CurState == 0);
            m_Poker[TempRand].CurState = 0;
        }
        TempRand = 0;
        for (int i = 0; i < 17; i++)
        {
            do
            {
                TempRand = rand() % 54;
                if (m_Poker[TempRand].CurState == 1)
                {
                    m_UserRight[i].PokerColor = m_Poker[TempRand].PokerColor;
                    m_UserRight[i].Poker = m_Poker[TempRand].Poker;
                }
            } while (m_Poker[TempRand].CurState == 0);
            m_Poker[TempRand].CurState = 0;
        }
        int var = 0;
    }
    //牌牌排序
    void PackagingClass::User_Sort(User *MainUser, int Len)
    {
        for (int i = 0; i < Len - 1; i++)
        {
            for (int j = i + 1; j < Len; j++)
            {
                if (MainUser[i].Poker > MainUser[j].Poker)
                {
                    User Temp = MainUser[i];
                    MainUser[i] = MainUser[j];
                    MainUser[j] = Temp;
                }
            }
        }
    }
    //加载牌牌
    void PackagingClass::LoadPoker()
    {
        // A   1    
        // B    2
        // C   3
        // D   4
    
        for (int i = 0; i < 17; i++)
        {
            switch (m_MainUser[i].PokerColor)
            {
            case 1:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dA.png", m_MainUser[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 2:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dB.png", m_MainUser[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 3:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dC.png", m_MainUser[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 4:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dD.png", m_MainUser[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            }
    
    
            switch (m_UserLeft[i].PokerColor)
            {
            case 1:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dA.png", m_UserLeft[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 2:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dB.png", m_UserLeft[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 3:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dC.png", m_UserLeft[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 4:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dD.png", m_UserLeft[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            }
    
    
            switch (m_UserRight[i].PokerColor)
            {
            case 1:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dA.png", m_UserRight[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 2:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dB.png", m_UserRight[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 3:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dC.png", m_UserRight[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            case 4:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dD.png", m_UserRight[i].Poker);
                Sprite *PokerSprite = CreateSprite(Buf);
            }; break;
            }
        }
    }
    //显示牌牌
    void PackagingClass::ShowPoker(Node *This)
    {
        int W = 35;
        int Width = 150;
        int MainY = 100;
    
        for (int i = 0; i < 17; i++)
        {
            switch (m_MainUser[i].PokerColor)
            {
            case 1:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dA.png", m_MainUser[i].Poker);
                Sprite *sprite = GetSprite(Buf);
                sprite->setPosition(Vec2(Width + W * (i * 1), MainY));
                This->addChild(sprite);
            }; break;
            case 2:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dB.png", m_MainUser[i].Poker);
                Sprite *sprite = GetSprite(Buf);
                sprite->setPosition(Vec2(Width + W * (i * 1), MainY));
                This->addChild(sprite);
            }; break;
            case 3:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dC.png", m_MainUser[i].Poker);
                Sprite *sprite = GetSprite(Buf);
                sprite->setPosition(Vec2(Width + W * (i * 1), MainY));
                This->addChild(sprite);
            }; break;
            case 4:
            {
                char Buf[64] = { 0 };
                sprintf_s(Buf, "Poker/%dD.png", m_MainUser[i].Poker);
                Sprite *sprite = GetSprite(Buf);
                sprite->setPosition(Vec2(Width + W * (i * 1), MainY));
                This->addChild(sprite);
            }; break;
            }
        }
    }
    //返回牌牌
    User *PackagingClass::GetUserMainUser()
    {
        return m_MainUser;
    }
    User *PackagingClass::GetUserLeft()
    {
        return m_UserLeft;
    }
    User *PackagingClass::GetUserRight()
    {
        return m_UserRight;
    }
    //出牌牌后牌牌再次排序后的位置更新
    void PackagingClass::OutPokerPostionUpdata(User *Poker__, int Len, int Width, int W, int MainY, Node *This)
    {
        int SUBLen = 0;//出掉的牌
        for (int i = 0; i < Len; i++)
        {
            if (Poker__[i].CurState != 1)//剩下的牌牌
            {
                switch (Poker__[i].PokerColor)
                {
                case 1:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dA.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    sprite->setPosition(Vec2(Width + (W * i), MainY));
                }; break;
                case 2:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dB.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    sprite->setPosition(Vec2(Width + (W * i), MainY));
                }; break;
                case 3:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dC.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    sprite->setPosition(Vec2(Width + (W * i), MainY));
                }; break;
                case 4:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dD.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    sprite->setPosition(Vec2(Width + (W * i), MainY));
                }; break;
                }
            }
            else//出掉的牌牌
            {
                switch (Poker__[i].PokerColor)
                {
                case 1:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dA.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    This->removeChild(sprite);
                    SUBLen++;
                }; break;
                case 2:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dB.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    This->removeChild(sprite);
                    SUBLen++;
                }; break;
                case 3:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dC.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    This->removeChild(sprite);
                    SUBLen++;
                }; break;
                case 4:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dD.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    This->removeChild(sprite);
                    SUBLen++;
                }; break;
                }
            }
        }
        for (int i = 0; i < Len; i++)
        {
            if (Poker__[i].CurState == 1)
            {
                for (int j = i + 1; j < Len; j++)
                {
                    if (Poker__[j].CurState == 0)
                    {
                        User Temp = Poker__[j];
                        Poker__[j] = Poker__[i];
                        Poker__[i] = Temp;
                        break;
                    }
                }
            }
        }
        float Offset = 0;
        float Starting = Width;//第一张的坐标
        float Ending = Width + (W * (Len - SUBLen - 1));//最后一张的坐标
    
        Starting -= 63;//精灵的宽的一半
        Ending += 63;//精灵的宽的一半
    
        Offset = (Starting + (800 - Ending)) / 2;//剩下的没有被牌所占的空间的一半
        Width = Offset + (Width / 2);//牌的偏移量
        for (int i = 0; i < Len - SUBLen; i++)
        {
            if (Poker__[i].CurState != 1)//剩下的牌牌
            {
                switch (Poker__[i].PokerColor)
                {
                case 1:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dA.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    sprite->setPosition(Vec2(Width + (W * i), MainY));
                }; break;
                case 2:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dB.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    sprite->setPosition(Vec2(Width + (W * i), MainY));
                }; break;
                case 3:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dC.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    sprite->setPosition(Vec2(Width + (W * i), MainY));
                }; break;
                case 4:
                {
                    char Buf[64] = { 0 };
                    sprintf_s(Buf, "Poker/%dD.png", Poker__[i].Poker);
                    Sprite *sprite = GetSprite(Buf);
                    sprite->setPosition(Vec2(Width + (W * i), MainY));
                }; break;
                }
            }
        }
    }
    //加载左边玩家的牌牌
    void PackagingClass::OutPokerLeftBackgroundUpdata(User *Poker_, int Len, Texture2D *Texture, Node *This)
    {
        float X = 100.0f;
        float Y = 20.0f;
        float Height = 200.0f;
        for (int i = 0; i < Len; i++)
        {
            Sprite *Temp = CreateTextureSprite(Texture);
            Temp->setRotation(90.0f);
            Temp->setScale(0.5f);
            Temp->setPosition(Vec2(X, Height + (i * Y)));
            This->addChild(Temp);
        }
    }
    //加载右边玩家的牌牌
    void PackagingClass::OutPokerRightBackgroundUpdata(User *Poker_, int Len, Texture2D *Texture, Node *This)
    {
        float X = 700.0f;
        float Y = 20.0f;
        float Height = 200.0f;
        for (int i = 0; i < Len; i++)
        {
            Sprite *Temp = CreateTextureSprite(Texture);
            Temp->setRotation(90.0f);
            Temp->setScale(0.5f);
            Temp->setPosition(Vec2(X, Height + (i * Y)));
            This->addChild(Temp);
        }
    }
    
    
    
    
    //五子棋
    DrawNode* PackagingClass::CreateGobangMap()
    {
        DrawNode *drawNode = DrawNode::create(3.5f);
        int Y = 550;
        int X = 50;
        for (int i = 0; i < 11; i++)
        {
            drawNode->drawLine(Vec2(50, Y), Vec2(550, Y), Color4F::BLACK);
            drawNode->drawLine(Vec2(X, 552), Vec2(X, 48), Color4F::BLACK);
            Y -= 50;
            X += 50;
        }
        return drawNode;
    }
    //标准坐标
    void PackagingClass::StandardPos(Sprite *Sprites)
    {
        float X = 50.0f;
        float Y = 550.0f;
        for (int i = 0; i < 11; i++)
        {
            for (int j = 0; j < 11; j++)
            {
                m_StandardPos[i][j] = Vec2(X * (j + 1), Y); //得到每一个格子的标准坐标
            }
            Y -= 50.0f;
        }
    
    
        for (int i = 0; i < 11; i++)
        {
            for (int j = 0; j < 11; j++)
            {
                if (Sprites->getPosition().x >= m_StandardPos[i][j].x - 25.0f && Sprites->getPosition().x <= m_StandardPos[i][j].x + 25.0f &&
                    Sprites->getPosition().y >= m_StandardPos[i][j].y - 25.0f && Sprites->getPosition().y <= m_StandardPos[i][j].y + 25.0f)
                {
                    Sprites->setPosition(m_StandardPos[i][j]);
                    return;
                }
            }
        }
    
    }
    
    
    
    
    
    
    
    
    //=======================================================================
    //注册每一帧调用:void class::Update(float Time);
    void PackagingClass::RegisterEachFrameCall(Node *node)
    {
        if (node)
        {
            node->scheduleUpdate();
        }
        return;
    }
    
    //注册鼠标事件
    void PackagingClass::RegisterMouseEvent(Node *node,
        MOUSEEVENTFUNCTION MouseDown,
        MOUSEEVENTFUNCTION MouseUp,
        MOUSEEVENTFUNCTION MouseMove,
        MOUSEEVENTFUNCTION MouseScroll)
    {
        if (node && MouseDown && MouseUp && MouseMove && MouseScroll)
        {
            MONITORBING MonitorBing;
            LPMONITORBING LPMonitorBing = &MonitorBing;
    
            LPMonitorBing->Dispatcher = Director::getInstance()->getEventDispatcher();
            LPMonitorBing->ListenerMouse = EventListenerMouse::create();
    
            //这里只能用兰姆达
            LPMonitorBing->ListenerMouse->onMouseDown = [=](Event *event)
            {
                PackagingClass::_OnMouseDown(MouseDown, event);
            };
            LPMonitorBing->ListenerMouse->onMouseUp = [=](Event *event)
            {
                PackagingClass::_OnMouseUp(MouseUp, event);
            };
            LPMonitorBing->ListenerMouse->onMouseMove = [=](Event *event)
            {
                PackagingClass::_OnMouseMove(MouseMove, event);
            };
            //LPMonitorBing->ListenerMouse->onMouseMove = OnMouseMove;
            LPMonitorBing->ListenerMouse->onMouseScroll = [=](Event *event)
            {
                PackagingClass::_OnMouseScroll(MouseScroll, event);
            };
    
            LPMonitorBing->Dispatcher->addEventListenerWithSceneGraphPriority(LPMonitorBing->ListenerMouse, node);
        }
        return;
    }
    void PackagingClass::RegisterMouseEvent(Node *node,
        MOUSEEVENTFUNCTION MouseDown,
        MOUSEEVENTFUNCTION MouseUp,
        MOUSEEVENTFUNCTION MouseMove)
    {
        if (node && MouseDown && MouseUp && MouseMove)
        {
            MONITORBING MonitorBing;
            LPMONITORBING LPMonitorBing = &MonitorBing;
    
            LPMonitorBing->Dispatcher = Director::getInstance()->getEventDispatcher();
            LPMonitorBing->ListenerMouse = EventListenerMouse::create();
    
            //这里只能用兰姆达
            LPMonitorBing->ListenerMouse->onMouseDown = [=](Event *event)
            {
                //EventMouse *M = (EventMouse*)event;
                //M->getCursorX();
                //FunctionCallBack(event);
                PackagingClass::_OnMouseDown(MouseDown, event);
            };
            LPMonitorBing->ListenerMouse->onMouseUp = [=](Event *event)
            {
                //EventMouse *M = (EventMouse*)event;
                //M->getCursorX();
                //FunctionCallBack(event);
                PackagingClass::_OnMouseUp(MouseUp, event);
            };
            LPMonitorBing->ListenerMouse->onMouseMove = [=](Event *event)
            {
                //EventMouse *M = (EventMouse*)event;
                //M->getCursorX();
                //FunctionCallBack(event);
                PackagingClass::_OnMouseMove(MouseMove, event);
            };
    
            LPMonitorBing->Dispatcher->addEventListenerWithSceneGraphPriority(LPMonitorBing->ListenerMouse, node);
        }
        return;
    }
    //注册按键事件
    void PackagingClass::RegisterKeyEvent(Node *node,
        KEYEVENTFUNCTION OnKeyDown,
        KEYEVENTFUNCTION OnKeyUp)
    {
        if (OnKeyDown && OnKeyUp)
        {
            EventDispatcher *Dispatcher = Director::getInstance()->getEventDispatcher();
            EventListenerKeyboard *KeyListener = EventListenerKeyboard::create();
            //KeyListener->onKeyPressed = CC_CALLBACK_2(HelloWorld::onKeyPressed, this);//按下
            //KeyListener->onKeyReleased = CC_CALLBACK_2(HelloWorld::onKeyReleased, this);//抬起
            KeyListener->onKeyPressed = [=](EventKeyboard::KeyCode KeyCode, Event *event)
            {
                PackagingClass::_OnKeyPressed(OnKeyDown, KeyCode, event);
            };
            KeyListener->onKeyReleased = [=](EventKeyboard::KeyCode KeyCode, Event *event)
            {
                PackagingClass::_OnKeyReleased(OnKeyUp, KeyCode, event);
            };
            Dispatcher->addEventListenerWithSceneGraphPriority(KeyListener, node);
        }
        return;
    }
    //注册触摸单点事件
    void PackagingClass::RegisterTouchEvent(Node *node,
        TOUCHEVENTFUNCTION OnTouchBegin,
        TOUCHEVENT_FUNCTION OnTouchMove,
        TOUCHEVENT_FUNCTION OnTouchEnd)
    {
        if (OnTouchBegin && OnTouchMove && OnTouchEnd)
        {
            //auto touchListener = EventListenerTouchOneByOne::create();
            //touchListener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
            //touchListener->onTouchMoved = CC_CALLBACK_2(HelloWorld::onTouchMoved, this);
            //touchListener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);
            //touchListener->onTouchCancelled = CC_CALLBACK_2(HelloWorld::onTouchCancelled, this);
            //Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(touchListener, this);
    
            EventDispatcher *Dispatcher = Director::getInstance()->getEventDispatcher();
            EventListenerTouchOneByOne *TouchListener = EventListenerTouchOneByOne::create();
            //可以直接赋值,是可以的
            //TouchListener->onTouchBegan = TouchBegin;
            //TouchListener->onTouchBegan = [ = ](Touch *touch, Event *event)->bool
            //{ 
            //    TouchBegin(touch,event);
            //    return true;
            //};
            //TouchListener->onTouchMoved = [=](Touch *touch, Event *event)
            //{
            //    TouchMove(touch, event);
            //};
            //TouchListener->onTouchEnded = [=](Touch *touch, Event *event)
            //{
            //    TouchEnd(touch, event);
            //};
    
            TouchListener->onTouchBegan = [=](Touch *touch, Event *event)->bool
            {
                return PackagingClass::_OnTouchBegin(OnTouchBegin, touch, event);
            };
            TouchListener->onTouchMoved = [=](Touch *touch, Event *event)
            {
                PackagingClass::_OnTouchMove(OnTouchMove, touch, event);
            };
            TouchListener->onTouchEnded = [=](Touch *touch, Event *event)
            {
                PackagingClass::_OnTouchEnd(OnTouchEnd, touch, event);
            };
            Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(TouchListener, node);
        }
        return;
    }
    void PackagingClass::RegisterTouchEvent(Node *node,
        TOUCHEVENTFUNCTION OnTouchBegin,
        TOUCHEVENT_FUNCTION OnTouchMove,
        TOUCHEVENT_FUNCTION OnTouchEnd,
        TOUCHEVENT_FUNCTION OnTouchCancelle)
    {
        if (OnTouchBegin && OnTouchMove && OnTouchEnd && OnTouchCancelle)
        {
            EventDispatcher *Dispatcher = Director::getInstance()->getEventDispatcher();
            EventListenerTouchOneByOne *TouchListener = EventListenerTouchOneByOne::create();
    
            TouchListener->onTouchBegan = [=](Touch *touch, Event *event)->bool
            {
                return PackagingClass::_OnTouchBegin(OnTouchBegin, touch, event);
            };
            TouchListener->onTouchMoved = [=](Touch *touch, Event *event)
            {
                PackagingClass::_OnTouchMove(OnTouchMove, touch, event);
            };
            TouchListener->onTouchEnded = [=](Touch *touch, Event *event)
            {
                PackagingClass::_OnTouchEnd(OnTouchEnd, touch, event);
            };
            //不知道有什么用
            TouchListener->onTouchCancelled = [=](Touch *touch, Event *event)
            {
                PackagingClass::_OnTouchCancelle(OnTouchCancelle, touch, event);
            };
            Director::getInstance()->getEventDispatcher()->addEventListenerWithSceneGraphPriority(TouchListener, node);
        }
        return;
    }
    
    
    
    void PackagingClass::_OnMouseDown(MOUSEEVENTFUNCTION MouseDown, Event *event)
    {
        MouseDown(event);
    }
    void PackagingClass::_OnMouseUp(MOUSEEVENTFUNCTION MouseUp, Event *event)
    {
        MouseUp(event);
    }
    void PackagingClass::_OnMouseMove(MOUSEEVENTFUNCTION MouseMove, Event *event)
    {
        MouseMove(event);
    }
    void PackagingClass::_OnMouseScroll(MOUSEEVENTFUNCTION MouseScroll, Event *event)
    {
        MouseScroll(event);
    }
    void PackagingClass::_OnKeyPressed(KEYEVENTFUNCTION OnKeyDown, EventKeyboard::KeyCode KeyCode, Event *event)
    {
        OnKeyDown(KeyCode, event);
    }
    void PackagingClass::_OnKeyReleased(KEYEVENTFUNCTION OnKeyUp, EventKeyboard::KeyCode KeyCode, Event *event)
    {
        OnKeyUp(KeyCode, event);
    }
    bool PackagingClass::_OnTouchBegin(TOUCHEVENTFUNCTION OnTouchBegin, Touch *touch, Event *event)
    {
        return OnTouchBegin(touch, event);
    }
    void PackagingClass::_OnTouchMove(TOUCHEVENT_FUNCTION OnTouchMove, Touch *touch, Event *event)
    {
        OnTouchMove(touch, event);
    }
    void PackagingClass::_OnTouchEnd(TOUCHEVENT_FUNCTION OnTouchEnd, Touch *touch, Event *event)
    {
        OnTouchEnd(touch, event);
    }
    void PackagingClass::_OnTouchCancelle(TOUCHEVENT_FUNCTION OnTouchCancelle, Touch *touch, Event *event)
    {
        OnTouchCancelle(touch, event);
    }
  • 相关阅读:
    OC 单例实现
    iOS 代码调试
    iOS
    iOS 11 scroll滚动偏移,tableview偏移44,获取view的宽和高
    swift 约束
    OC
    OC 线程操作
    OC 线程操作
    【第35题】2019年OCP认证12C题库062考试最新考试原题-35
    【第34题】2019年OCP认证12C题库062考试最新考试原题-34
  • 原文地址:https://www.cnblogs.com/YZFHKMS-X/p/11780620.html
Copyright © 2020-2023  润新知