Coco2dx制作一个3D旋转的效果
2015-06-28 00:55
381 查看
建了工程之后修改HelloWorldScene.cpp文件,修改部分为
HelloWorldScene.h也要修改
然后就可以看到旋转效果:
// on "init" you need to initialize your instance bool HelloWorld::init() { ////////////////////////////// // 1. super init first if ( !Layer::init() ) { return false; } ry = 0; auto rootNode = CSLoader::createNode("MainScene.csb"); addChild(rootNode); Size visibleSize = Director::getInstance()->getVisibleSize(); s = Sprite::create("HelloWorld.png"); s->setAnchorPoint(Vec2(0, 0.5f)); s->setPosition(visibleSize.width / 2, visibleSize.height / 2); addChild(s); scheduleUpdate(); return true; } void HelloWorld::update(float dt) { ry++; s->setRotation3D(Vec3(0, ry, 0)); }
HelloWorldScene.h也要修改
class HelloWorld : public cocos2d::Layer { private: cocos2d::Sprite *s; float ry; public: // there's no 'id' in cpp, so we recommend returning the class instance pointer static cocos2d::Scene* createScene(); // Here's a difference. Method 'init' in cocos2d-x returns bool, instead of returning 'id' in cocos2d-iphone virtual bool init(); // implement the "static create()" method manually CREATE_FUNC(HelloWorld); void update(float dt); };
然后就可以看到旋转效果:
相关文章推荐
- Coco2dx制作一个3D旋转的效果
- acm常见算法及例题
- Linux 目录结构及文件基本操作
- 路由器缓冲区大小为什么如此重要
- 路由器缓冲区大小为什么如此重要
- [Swust OJ 838]--最优价值(0-1背包+数学)
- 推荐近期15个 Node.js 开发工具
- 告别臃肿~精简安装Visual Studio 2012
- android NDK中sqlite3数据库的使用
- Codeforces Round #310 (Div. 1) A. Case of Matryoshkas 水题
- spring学习笔记(1)——spring介绍
- [Codeforces Round #310 (Div. 2)] #ABC题解
- Codeforces Round #310 (Div. 2)
- 博客订阅Feed地址托管到GAE
- LeetCode——Search for a Range
- DP项目开发随记5-攀爬初步完成
- 有了装逼大全,谁也阻止不了我装逼了
- 定义一个Block
- PHP本地实现虚拟域名访问:Apache虚拟主机配置
- leetcode解题报告228——Summary Ranges