设为首页 加入收藏

TOP

仿《雷霆战机》飞行射击手游开发--新手引导(五)
2017-10-13 10:14:57 】 浏览:3255
Tags:《雷霆战机》 飞行 射击 开发 新手 引导
m_touchEnable = false;

销毁新手引导层,将目标按钮挂到原来的父节点上。 

//还原target
void Guide::restore()
{
	if (m_pTarget)
	{
		m_pTarget->retain();

		this->getChildren().eraseObject(m_pTarget);
		m_targetParent->addChild(m_pTarget);
		m_pTarget->setLocalZOrder(m_targetLocalZOrder);
		m_pTarget->setPosition(m_targetPos);

		m_pTarget->release();
	}

	this->removeFromParent();
}

新手引导子类

这里我们简单介绍第一个美女欢迎和主菜单这两个新手引导。

 

////////////////////////////////////////////////////////////////
//
//  首次进入游戏的介绍
//
////////////////////////////////////////////////////////////////
class GuideWelcomeGirl : public Guide
{
public:
	DECLARE_GUIDE(GuideWelcomeGirl);

public:
	virtual bool doInit() override;
};

////////////////////////////////////////////////////////////////
//
//  首次进入游戏,点击闯关模式
//
////////////////////////////////////////////////////////////////
class GuideWelcomeClickButtonLevel : public Guide
{
public:
	DECLARE_GUIDE(GuideWelcomeClickButtonLevel);

public:
	virtual bool doInit() override;
};

  

////////////////////////////////////////////////////////////////
//
//  首次进入游戏的介绍
//
////////////////////////////////////////////////////////////////
REGISTER_GUIDE(GuideType::WelcomeGirl, GuideWelcomeGirl);

bool GuideWelcomeGirl::checkCondition()
{
	switch (GuideConstant::GuideDisplay)
	{
	case GuideTestNoGuide:   return false;//用于测试
	case GuideTestNecessary: return true; //用于测试
	default:
		return !GameData::getInstance()->checkGuide(mType)
			&& GameData::getInstance()->getLevelFinish(Difficulty::Easy) == 0;
	}
}

bool GuideWelcomeGirl::doInit()
{
	Guide::setPrompt(GlobalData::getInstance()->getParameter(GuideConstant::StringGuideWelcome));

	if (!Guide::doInit())
	{
		return false;
	}

	return true;
}

////////////////////////////////////////////////////////////////
//
//  首次进入游戏,点击闯关模式
//
////////////////////////////////////////////////////////////////
REGISTER_GUIDE(GuideType::WelcomeClickButtonLevel, GuideWelcomeClickButtonLevel);

bool GuideWelcomeClickButtonLevel::checkCondition()
{
	switch (GuideConstant::GuideDisplay)
	{
	case GuideTestNoGuide:   return false; //用于测试
	case GuideTestNecessary: return true; //用于测试
	default:
		return !GameData::getInstance()->checkGuide(mType)
			&& GameData::getInstance()->getLevelFinish(Difficulty::Easy) == 0;
	}
}

bool GuideWelcomeClickButtonLevel::doInit()
{
	Guide::setPrompt(GlobalData::getInstance()->getParameter(GuideConstant::StringGuidePressLevelMode));

	if (!Guide::doInit())
	{
		return false;
	}

	return true;
}

仔细比较这两个新手引导代码,最大的区别点就在checkCondition函数,也就是判断当前的条件是否需要显示引导。然后,设置下需要现实的文字说明,接着,没了。

引导管理类

class GuideMgr
{
public:
	static GuideMgr* getInstance();

	bool registerFunc(int type, const std::function<bool()>& checkFunc, const std::function<Guide*()>& createFunc);

	Guide* show(int GuideType, Node* parent, Node* widget, const std::function<void()>& callback = nullptr);
	bool destory(int GuideType);

	void incGuideCnt();
	void decGuideCnt();
	bool hasGuide();

protected:
	GuideMgr();

private:
	std::map<int, std::fu
首页 上一页 2 3 4 5 下一页 尾页 5/5/5
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇13:图像模糊处理 下一篇ReplaceChar

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目