Skip to content

zhanghuanchong/EatNum

Repository files navigation

EatNum Game

Developed with Cocos2d-x v3.2, by Hans Zhang (ezburg@gmail.com).

Screenshots

Home

Chapters

Levels

Game scene

Pass

C++11 feature: Lambda

btnNext = ScalableSprite::create("next.png", 
	[this, nextChapter, nextLevel, showNext]() {
		m_doneLayer->removeFromParent();
		m_doneLayer = nullptr;
		m_nChapter = nextChapter;
		m_nLevel = nextLevel;
		this->loadLevel();
		this->scaleBlocks(0);
	}
);

STL std:function

typedef std::function<void(Ref *, Touch *, Event *)> touchCallback;

Customized Node

class Block : public Node
{
CC_CONSTRUCTOR_ACCESS:
	virtual ~Block() {}

	virtual bool init(const Color4B& bgColor, 
		const string& title, 
		const touchCallback& onTouchEnd,
		const touchCallback& onTouchBegan,
		const touchCallback& onTouchMoved,
		const touchCallback& onTouchCancelled);
};

And its sub class:

class DraggableBlock : public Block
{
	// ...
};

Cross platform support classes

  • CrossHelper
  • CrossiOS
  • CrossAndroid

Simple Cocos2d-x Class generator

Run on windows:

Classes/CreateCocos2dxClass.exe