如何在Android Cocos2D中只绘制一部分精灵表到CCGLSurfaceView?

时间:2011-08-25 08:37:34

标签: android sprite-sheet cocos2d-android

我从here开始使用Android Cocos2D。我看到可以直接添加精灵图像。

然而,我已经拥有了一张巨大的精灵表,它获得了游戏中使用的每一个精灵。

在Cocos2D中是否存在某种函数调用,我只需指定“我想从精灵表中将一部分(x1,y1)绘制到(x2,y2)到CCGLSurfaceView上的某个位置”?

1 个答案:

答案 0 :(得分:0)

不推荐使用CCSpriteSheet。最好使用CCSpriteBatchNode(实际上它们非常相似)。您可以从batchNode创建精灵:

CCSprite *sprite = [CCSprite spriteWithBatchNode:batch rect:CGRectMake(x1, y1, x2, y2)];

那是Objective-c代码,但我认为Android版本中有相同的功能