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
?
轉載于:https://www.cnblogs.com/yuedongdeguangzi/p/8668870.html
總結
以上是生活随笔為你收集整理的cocos2dx实现单机版三国杀(二)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OpenCV从入门到精通——边缘检测算法
- 下一篇: 等面积圆柱投影的证明