前情回顾

通过CCMainMenu的init函数,已经把所有的按钮,棋子都摆放完毕了,但是这个时候,棋子是不能走动的,只有在开始游戏之后才能移动棋子。

点击aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGIAAAAqCAIAAADHzBlYAAAZEklEQVRoge1aZ1cbWbYtSSCVhJAQIJLICmQQyoickVAgIzKoqgAnEBiTgxA4ttttYt0yNhiHGac2GJw9Pf3eWzPP3TaqUs967/+8DyXcnu7+yKe3+q697iqkWqV7t87ZZ58rIOjP8ef4c/w5/hz/z8drT8Nrd/3hgv1gru5wzvpmwfrebXnvtn3w2D947G8XrIfTNfsTlYfT1W8XLO8X7e8WrC9nal7MVO/N1ezPm17Mmw4WzAfu2oMF86G79nDBfLBgfjFvejFXszdb/Xyuet9t2vfU7i2a9z3mPY9531O7v2R5sWSlcbBsO7hoe3HRduCufTFvejFnOjieD+bNhwvmwwXzS7fl1aLl1aL1lcf6yl37Zrb63UzVh3nzh3nLm1nz61nzq+maw6nqF9M1rxdsf7vU/OFS48t5y96s5flCw4Gn6XC5+QRoejNf+2rO9GKq6vmFiucjJYfDBYfnjAdDxpfDBS+Hi1+cy//+lPbpgPr5af1LV+Gb8yWvR4oOzhiendE/Opf3+Jz+yTnD06G8r/FkyPDknOHxWf2jM4bHZ/OeuPKejuY/cRkfD+c9cRkfu4yPR/IfufIfuYyPXMZHw/Sc9/Sc4dkZ/fMzBhp7Xy7OGvbOGvbP5e2dMz4fyt87Z9wf1B4MaF8O6l/06/b6Nc8HNM8HtM8HNN8P6vfP5b8cKf3+dN6dzvRtJPfReOW+2/ZqyX4CNL2eqdifKHk6ZLg/mHsfUT7r0z/t0j7qyHnSmfu0W/24S/2wXXmvNethm/Jxl+ZZr/5pt/avbcr7HcrdHtW9btX9btX9btWDHvWDHvW9HvW9HtW9LtW9rtzdYzzoUj3sUt3vzL3fobzXkb3bnnW3LXPHkbHdkn6nJe12c+qt5rStprTthrTd+pTdOj/u1inu1il2bPI7NsUdu+K2TXbHJt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aWjQRl61bV2z3l8zfT1UeTptfuW0nQNOf48/x5zih8X9shrXF84hMkgAAAABJRU5ErkJggg==" alt="" />按钮,开始游戏,那么点击开始按钮之后,程序究竟发生了什么事,我们继续看代码到创建这个开始按钮的地方。

开始按钮的创建

开始按钮的创建代码,在上一篇博文中有所提起,但是没有重点提及,是在CCMainMenu::init()函数中

// 开始按钮
pItem = CCMenuItemImage::create(RES_PATH"start.jpg", RES_PATH"start.jpg", this, menu_selector(CCMainMenu::menuStart));
pItem->setPosition(ccp(m_fPositionX - s.width/6, m_fPositionY - s.height/8*3));
pItem->setAnchorPoint(CCPointZero);
pItem->setScaleX(0.667f);
pItem->setScaleY(0.6f); // pMenu = CCMenu::create(pItem, NULL); xueguoliang
pMenu = CCMenu::create(pItem, NULL);
pMenu->setPosition(CCPointZero);
this->addChild(pMenu, 1);

从上面一段创建开始按钮的代码中,在第一句创建item的代码中,我们见到在第一句中,menu_selector括号中的CCMainMenu::menuStart

所指是启动按钮被点击时,menuStart函数将会被调用。

menuStart函数

void CCMainMenu::menuStart(CCObject* pSender)
{
if(m_enGameStatus != GAME_MENU)
{
return;
}
this->schedule(schedule_selector(CCMainMenu::updateFocus), 0.5f);
m_enGameStatus = GAME_RUNNING;
m_nChessTime = 600;
this->setNumberSprite(m_nChessTime);
}

menuStart函数,主要修改游戏状态为GAME_RUNNING,这个状态让棋子点击有效。

ccTouchesEnded

这个函数是鼠标点击函数,没走一步棋子至少需要鼠标点击两次,一次是选中,一次是移动。都是在这个函数里处理

void CCMainMenu::ccTouchesEnded(CCSet* pTouches, CCEvent* pEvent)
{
if(m_enGameStatus != GAME_RUNNING)
{
return;
}
CCSetIterator it = pTouches->begin();
CCTouch* pTouch = (CCTouch*)(*it);
CCPoint touchPoint = pTouch->getLocationInView();
touchPoint = CCDirector::sharedDirector()->convertToGL(touchPoint);
this->dealWithChess(touchPoint.x, touchPoint.y);
}

这个函数首先判断现在游戏状态,是不是GAME_RUNNING,如果不是,则直接返回
否则,获取坐标点,然后调用dealWithChess函数

dealWithChess

dealWithChess函数时已经确定了在游戏中时,鼠标点击了棋盘中的点

这个函数负责棋子选中和移动的逻辑,详细的代码和注释见如下:

void CCMainMenu::dealWithChess(float x, float y)
{
// 判断是不是棋盘范围
if (x < 24 || x > 294 || y < 14 || y > 312)
{
return;
} CCSprite* pSprite; // 获取该坐标点上的棋子
pSprite = this->getChessByCoord(x, y);
if(!this->getChessByCoord(x, y, 1))
{
// can not find coordinate
return;
}
int x0 = static_cast<int>(x);
int y0 = static_cast<int>(y);
if (pSprite) // 如果点中了每个棋子
{
if(m_bSelect) // 如果之前有选中某个棋子
{
m_pTargetChess = pSprite; // 那么这次选中的棋子是目标
}
else // 如果没选中,那么这次点的棋子是选中的棋子
{
if (!m_nCur && m_enCurChessType < CHESS_BORDER)
{
return;
}
else if(m_nCur && m_enCurChessType > CHESS_BORDER)
{
return;
} m_pFocus->setPosition(pSprite->getPosition());
m_pFocus->setVisible(true);
m_pCurChess = pSprite;
ox = x0;
oy = y0;
m_bSelect = false;
}
} if (m_bSelect)
{
if(!this->judgeAction(x0, y0))
{
this->clean();
return;
}
if((m_enCurChessType < CHESS_BORDER && m_enTarChessType < CHESS_BORDER && m_enTarChessType > CHESS_NONE) ||
(m_enCurChessType > CHESS_BORDER && m_enTarChessType > CHESS_BORDER))
{
this->clean();
return;
}
if(m_pTargetChess && m_pTargetChess != m_pCurChess)
{
m_pTargetChess->setVisible(false);
this->collectInfo(m_pTargetChess);
}
this->collectInfo(m_pCurChess);
CCPoint p = g_chess_coord[x0][y0];
m_pCurChess->setPosition(p);
m_pFocus->setPosition(p);
g_cur_map[x0][y0] = g_cur_map[ox][oy];
g_cur_map[ox][oy] = 0;
//this->print();
m_nCur = m_nCur == 0 ? 1 : 0;
this->clean();
this->judgeWin();
}
else
{
m_bSelect = true;
}
}

cocos2d-x游戏开发系列教程-中国象棋05-开始游戏的更多相关文章

  1. cocos2d-x游戏开发系列教程-中国象棋00-前言

    象棋描述 在说代码之前,我们先让象棋效果登场,以方便大家对代码的理解 欢迎界面 中国象棋程序,运行起来的第一个界面是一个欢迎界面,该欢迎界面在停留一秒后进入游戏界面 游戏主界面 新局:所有棋子归位,状 ...

  2. cocos2d-x游戏开发系列教程-中国象棋02-main函数和欢迎页面

    之前两个博客讲述了象棋的规格和工程文件之后,我们继续深入的从代码开始学习cocos2dx 首先从程序入口main函数开始 main函数 int APIENTRY _tWinMain(HINSTANCE ...

  3. cocos2d-x游戏开发系列教程-中国象棋01-工程文件概述

    上一篇博文我们看到了象棋的效果图,这一张我们来看象棋代码的整体概述 让我们先对整个代码框架有个了解. 主目录: 主目录包含内容如上图: classes目录:业务代码 proj.win32:包括main ...

  4. cocos2d-x游戏开发系列教程-中国象棋03-主界面

    前情回顾 上个博客说道我们象棋程序进入了欢迎界面,在欢迎界面下等待一秒进入主界面 进入主界面的关键代码如下: CCScene* pScene = CCMainMenu::scene();  创建sce ...

  5. cocos2d-x游戏开发系列教程-中国象棋06-游戏规则

    前情回顾 上一个博文我们提到象棋运动的函数dealWithChess,但是只是说该函数完成了棋子的选择和移动功能 其实在这个函数里,在移动棋子之前,是要对棋子的移动是否合法进行判断的,我们一起来看看如 ...

  6. cocos2d-x游戏开发系列教程-中国象棋04-摆棋

    前情回顾 在之前的学习中,我们已经了解到,下棋主界面是由CCMainMenu类实现的,在它的init函数中,初始化了 主界面需要的各种数据,包括:创建控件,初始化32个棋子,初始化执行变量等等,在这个 ...

  7. HTML5游戏开发系列教程7(译)

    原文地址:http://www.script-tutorials.com/html5-game-development-lesson-7/ 今天我们将完成我们第一个完整的游戏--打砖块.这次教程中,将 ...

  8. HTML5游戏开发系列教程6(译)

    原文地址:http://www.script-tutorials.com/html5-game-development-lesson-6/ 这是我们最新一篇HTML5游戏开发系列文章.我们将继续使用c ...

  9. HTML5游戏开发系列教程5(译)

    原文地址:http://www.script-tutorials.com/html5-game-development-lesson-5/ 最终我决定准备下一篇游戏开发系列的文章,我们将继续使用can ...

随机推荐

  1. quartz搭建与应用

    1.添加依赖 依赖包括Quartz和logback <dependencies> <dependency> <groupId>org.quartz-schedule ...

  2. BZOJ 1634: [Usaco2007 Jan]Protecting the Flowers 护花( 贪心 )

    考虑相邻的两头奶牛 a , b , 我们发现它们顺序交换并不会影响到其他的 , 所以我们可以直接按照这个进行排序 ------------------------------------------- ...

  3. java-StringTokenizer类

    StringTokenizer类别可以通过某个字符或者多个字符作为分界符,来将字符串划分为多个标记(token). package com.example.helloworld; import jav ...

  4. django user模块改写

    示例一:继承AbstractBaseUser,AbstractBaseUser只有三个字段password,last_login,is_active,以及需要复习的两个方法 def get_full_ ...

  5. python 模块BeautifulSoup使用

    BeautifulSoup是一个专门用于解析html/xml的库.官网:http://www.crummy.com/software/BeautifulSoup/ 说明,BS有了4.x的版本了.官方说 ...

  6. poj 2250 Compromise(区间dp)

    题目链接:http://poj.org/problem?id=2250 思路分析:最长公共子序列问题的变形,只是把字符变成了字符串,按照最长公共子序列的思路即可以求解. 代码如下: #include ...

  7. Java for循环用法

    Java中for循环多了一种写法--foreach写法(一般仅仅用于遍历整个数组,不用操心越界等问题). 1.1)常规写法: package foreach.main.sn; public class ...

  8. Android -- BroadCastReceiver的简单使用

    //首先新建一个继承自BroadcastReceiver的广播监听类 class StartActiviryReceiver extends BroadcastReceiver { public fi ...

  9. SSH框架入门学习之二(spring)

    Spring也是一个开源框架,我在学习Spring的时候,认为最重要的几点是:IOC(控制反转).AOP(面向切面)和容器概念. 详细的教程还请大家去看网上的视频,这里贴一个小Demo以供学习. (前 ...

  10. stm32之595(spi芯片)

    595是一款串转并的芯片:  (三极管的功能) /*Include---------------------------*/ #include"stm32f10x_lib.h" / ...