cocos2d-x学习一文档阅读

UI Coordinate System

Cocos2d-x/-html5/-iphone 与OpenGL使用相同Coordinate System,右手坐标系。


在2D世界只用x,y轴,原点在屏幕左下角


Parent and Childrens

每个类继承于 CCNode  (Ultimate cocos2d-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

frame animation 容易理解但很少使用,反而使用  sprite sheet animation

coocs2d-x的基本部分间的关系图:



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器学习模型机器
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MyObject-C

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值