Cocos2dx内的坐标系(Coordinate Systems In Cocos2dx)

窗口坐标系:即openGL坐标系,左下角为原点,向右是x正方向,向上是y正方向。

纹理坐标系:左上角为原点,向右是x正方向,向下是y正方向。在使用图集时,例如截取其中的某个矩形块来创建一个sprite会用到此坐标系。


Window Coordinate System: which uses the openGL coordinate system, has an origin at the left bottom corner, x increases towards the rightside and y increases towards the upside.

Texture Coordinate System: which has an origin at the top left corner, with x increasing towards the rightside and y increasing towards the downside.This coordinate system will be used when you use a tileset, like using a rect from it to create a sprite.


code example:

CCSpriteBatchNode* batchnode = CCSpriteBatchNode::create("data/tileset/grass.png");
CCSprite* sprite= CCSprite::createWithTexture(batchnode->getTexture(), CCRectMake(0,0,48,32));
batchnode->addChild(bnsprite);
this->addChild(batchnode);

The second line in this code fragment, created an sprite,using a 48*32 rect on the top left corner of the texture.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值