cocos2d-x学习一文档阅读
2014-03-23 19:32
295 查看
UI Coordinate System
Cocos2d-x/-html5/-iphone 与OpenGL使用相同CoordinateSystem,右手坐标系。
在2D世界只用x,y轴,原点在屏幕左下角
Parent and Childrens
每个类继承于CCNode (Ultimatecocos2d-x class)的子类都有定位点属性。
绘制对象时cocos2d-x结合所有特性位置和定位点,旋转对象时,围绕定位点旋转。
x= anchorPoint.x*图形宽度
y= anchorPoint.y*图形高度
x,y作为图形的坐标。
// create sprite CCSprite* sprite = CCSprite::create("center.png"); sprite->setAnchorPoint(ccp(0.5, 0.5));// Anchor Point sprite->setPosition(ccp(0,0)); addChild(sprite);图形的坐标是中点,图形的位置在屏幕的(0,0)位置。
How to convert co-ordinates
convertToNodeSpace:
把node2的坐标转化成相对于node1的本地坐标系的坐标位置。
CCPoint point = node1->convertToNodeSpace(node2->getPosition());
convertToWorldSpace:
把node2的坐标转化成相对于node1的世界坐标系的世界坐标位置。
CCPoint point = node1->
convertToWorldSpace(node2->getPosition());
Scheduler and Timer Callback
Update selector:每帧都会被调用,可以定制优先级。Custom
selector:每帧都会被调用,或带有时间间隔。
Custom
selectors 应该尽可能避免, Update selectors更快、节省内存。
CCScheduler vs. NSTimer
The Cocos2D Scheduler provides your game with timed events and calls.You should not use NSTimer. Instead use CCScheduler class.
Actions
如果属性在一段时间内更改,他们是CCIntervalAction actions,否则是CCInstantAction actions。
Animations
frameanimation 容易理解但很少使用,反而使用 sprite sheet animation
。
coocs2d-x的基本部分间的关系图:
相关文章推荐
- Java学习之道:java实现文档的在线阅读功能
- Kafka学习(1)——kafka文档阅读笔记
- Cocos2d-x 3D功能学习笔记 分类: cocos2d代码编写 2015-07-27 18:57 8人阅读 评论(0) 收藏
- VLC 学习计划---(1)文档阅读
- Cocos2d-x创建和转换场景学习笔记 分类: cocos2d代码编写 2015-07-27 17:38 8人阅读 评论(0) 收藏
- Cocos2d-x中的基础概念学习笔记 分类: cocos2d代码编写 2015-07-27 17:08 5人阅读 评论(0) 收藏
- Cocos2d-x 音频功能学习笔记 分类: cocos2d代码编写 2015-07-27 19:02 8人阅读 评论(0) 收藏
- cocos2d lua 学习文档
- 英语学习—阅读文档感悟
- graphql学习(一)graphql-java文档初步阅读
- VLC 学习计划---(1)文档阅读
- VLC 学习计划---文档阅读
- Cocos2d-x 文件系统学习笔记 分类: cocos2d代码编写 2015-07-27 19:04 5人阅读 评论(0) 收藏
- 阅读Oracle官方文档一步步学习Oracle知识的正确顺序
- Cocos2d-x精灵学习笔记 分类: cocos2d代码编写 2015-07-27 17:17 5人阅读 评论(0) 收藏
- Cocos2d-x事件分发机制学习笔记 分类: cocos2d代码编写 2015-07-27 18:02 6人阅读 评论(0) 收藏
- cocos2d-android学习文档
- ADO学习(九)如何阅读ADO文档
- Blockly学习之文档阅读笔记
- Structured Streaming Programming Guide官方文档再次阅读理解强化学习