窗口坐标系:即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.
理解OpenGL与纹理坐标系在游戏开发中的应用

本文深入探讨了窗口坐标系与纹理坐标系在游戏开发中的作用,通过代码实例展示了如何使用图集创建精灵,并解释了坐标系在这一过程中的重要性。
2051

被折叠的 条评论
为什么被折叠?



