Cocos2dx之CCLabelBMFont类

C++之旅 QQ群:201704374

伸手党的救星,1T资料等你来战



一、CCLabelBMFont


二、程序设计和实现

#ifndef __T10CCLabelBMFont_H__
#define __T10CCLabelBMFont_H__
#include "cocos2d.h"
USING_NS_CC;


class T10CCLabelBMFont : public CCLayer
{
public:
	T10CCLabelBMFont(void);
	~T10CCLabelBMFont(void);

	static CCScene* scene();
	CREATE_FUNC(T10CCLabelBMFont);
	bool init();
};

#endif
#include "T10CCLabelBMFont.h"


T10CCLabelBMFont::T10CCLabelBMFont(void)
{
}


T10CCLabelBMFont::~T10CCLabelBMFont(void)
{
}


CCScene* T10CCLabelBMFont::scene()
{
	CCScene* scene = CCScene::create();
	T10CCLabelBMFont* layer = T10CCLabelBMFont::create();
	scene->addChild(layer);
	return scene;
}

bool T10CCLabelBMFont::init()
{
	CCLayer::init();

	CCLabelBMFont* font = CCLabelBMFont::create("asdfghj", "bitmapFontTest.fnt");
	addChild(font);
	font->setPosition(ccp(240, 160));

	CCArray* arr = font->getChildren();
	CCSprite* A = dynamic_cast(arr->objectAtIndex(0));
	CCSprite* B = dynamic_cast(arr->objectAtIndex(1));

	A->runAction(CCJumpBy::create(10, ccp(0, 0), 30, 10));
	B->runAction(CCMoveBy::create(10, ccp(100, 0)));
	return true;
}



三、实验现象

Cocos2dx之CCLabelBMFont类_第1张图片

你可能感兴趣的:(Cocos2d-x)