zoukankan      html  css  js  c++  java
  • cocos2dx实现单机版三国杀(二)

    接上续,东西还没有做完 所以代码免不了改动

    之前的头文件现在又改了不少,因为架构也改变了现在主要类就是GameScene、GameUI、PlayInfo、Poker这四个类  前面想的GameLoop 已经被弃

    目前除了身份、武将等相关的高级功能还没添加,基本功能只剩下 出牌策略没做了。

    贴一下GameUI新的头文件

    #pragma once
    /*
    主游戏界面UI

    */

    #include "cocos2d.h"
    #include "ui/CocosGUI.h"


    USING_NS_CC;
    class PlayInfo;
    class Poker;
    class GameUI:public cocos2d::Layer
    {
    //friend class GameScene;
    public:
    bool init();

    virtual void onEnter();
    virtual void onExit();

    void menuReOpen(Ref*pSender);//重开
    void menuExit(Ref*pSender);//退出游戏
    void menuaddpoker(Ref*pSender);
    void menuusepoker(Ref*pSender);
    void menugiveuppoker(Ref*pSender);

    void update(float delta);
    /* 玩家摸牌 显示 */
    void addPoker( int ,int);
    /* 玩家使用牌(包括回合内外) 显示 */
    void usePoker(int num=1);
    /* 玩家弃牌 显示 */
    void giveupPoker( );
    /* 电脑玩家弃牌 显示*/
    void giveupPoke_Robot(int );
    void fun1(Ref*);
    /*弃牌堆的更新*/
    void Updategiveupheap();

    CREATE_FUNC(GameUI);

    //初始化角色信息
    void initRoleInfo(PlayInfo* player);
    //更新角色信息(显示)
    void UpdateRoleInfo(PlayInfo*player);

    //初始化对手信息
    void initFoeInfo(PlayInfo* player);
    //更新对手信息(显示)
    void UpdatFoeInfo(PlayInfo*player);

    Label*CurrenState;
    bool isAddPoker;
    void CountDown(float dt=5.0f);//倒计时函数实现延时功能
    void setTimeBarwithtime(float );
    bool isCountDown;//是否在读条 即调用了CountDown
    bool isEndUsePokeState;//是否结束出牌阶段

    void SwapTimeBar();//交换当前回合的时间读条指针,令当前回合进行读条的Loadingbar 指针指向play的时间读条指针

    void UpdateShowPokerSlot(PlayInfo*);//更新手牌槽,外部调用
    void DrawShowPokerSlot();//绘制手牌槽的牌
    void addgiveupheap(Poker*);//添加牌到弃牌堆
    private:
    std::vector<Poker*>showpokerslot;//玩家需要显示的手牌槽
    std::vector<int>showIntslot;
    std::vector<Poker*>giveupPokerHeap;//弃牌堆
    Sprite*bg;//背景图片
    Sprite*equipment;//装备栏图片
    Sprite*pokerSlot;//手牌槽背景图片
    Sprite*rolePicInfo;//角色ui图片信息
    //Vector<Sprite*>roleHealthInfo;

    Sprite*foeInfoShow;

    ui::LoadingBar* timebar;
    ui::LoadingBar* timebarRobot;

    Label* timelabel;

    Label*_showOurPokerNums;
    Label*_showFoePokerNums;


    };

     ------------------------------

    虽然还有很多坑,但是基本流程是完成了

    暂时放下来,有时间再填坑

    https://github.com/huzhongyidihao/sanguosha

  • 相关阅读:
    评论聊聊怎样做一个简单的网站APP-博客网app那种
    vs2019 filesystem問題 #error The <experimental/filesystem> header providing std::experimental::filesystem is deprecated by Microsoft 。。。
    C#面试题整理
    0717的一个错误写法
    颜色相关的算法整理
    C/C++ 获取键盘事件
    网摘-按键精灵屏幕找色原理分析
    数值统计
    平方和与立方和
    求奇数的乘积
  • 原文地址:https://www.cnblogs.com/yuedongdeguangzi/p/8668870.html
Copyright © 2011-2022 走看看