1.下载准备:
freetype2:http://download.savannah.gnu.org/releases/freetype/
扩展库:https://github.com/happykevins/cocos2dx-ext
2.搭建环境
2.1 配置freetype2
2.2.创建工程,添加文件,如下:
工程根目录:
class文件夹:
vs2010工程目录:
3. 代码:
HelloWorldScene.h
- #ifndef__HELLOWORLD_SCENE_H__
- #define__HELLOWORLD_SCENE_H__
-
- #include"cocos2d.h"
- #include"cocos-ext.h"
- #include<renren-ext.h>
- USING_NS_CC;
- USING_NS_CC_EXT;
- classHelloWorld:publiccocos2d::CCLayer
- {
- public:
-
- virtualboolinit();
-
- staticcocos2d::CCScene*scene();
-
- //aselectorcallback
- voidmenuCloseCallback(CCObject*pSender);
- //implementthe"staticnode()"methodmanually
- CREATE_FUNC(HelloWorld);
- boolccTouchBegan(CCTouch*pTouch,CCEvent*pEvent);
- voidccTouchMoved(CCTouch*pTouch,CCEvent*pEvent);
- //HTMLevents
- voidonHTMLClicked(
- IRichNode*root,IRichElement*ele,int_id);
- voidonHTMLMoved(
- int_id,
- constCCPoint&location,constCCPoint&delta);
- };
- #endif//__HELLOWORLD_SCENE_H__
HelloWorldScene.cpp