接下来的这个问题:
How should I go about animating over 200 images in iOS?
我想知道如何在Xcode中使用纹理地图集,但不是在cocos2d中。这个项目已经完成了太多,我现在不能把它移植到cocos2d上。这也将是唯一具有此数量图像的动画。
唯一的教程似乎涉及到cocos2d或corona。我已经下载了Zwoptex,并打包了我所有的精灵,但即使这样,我也不确定是否应该修剪它们,允许旋转,给它们填充,甚至是我如何处理我的视网膜图像。
我一直在看这个链接:http://mysterycoconut.com/blog/2011/01/cag1/,这是我在上一个问题中推荐给我的,但它似乎掩盖了我正在苦苦挣扎的许多部分。
如果能帮上忙我会很感激的。
发布于 2012-07-05 04:01:22
纹理图集是为运行Cocos2D而设计的,与其他组件有很多依赖关系。所以我认为这对你来说不是一个好的选择。
你发布的教程在其他方面都很好。它可能最容易使用,但它提供了一个非常好的入口点。这段代码的主要部分是- display
和- (void)displayLayer:
方法:
当层需要其内容时,调用display方法。动画将(间接地)调用display方法,这里我们调用displayLayer,它将更改要显示的图像(我希望我已经说得很清楚了:!)。
如果您想使用非固定大小的zwooptex文件(或其他文件),您可以如何重构display方法:
// Implement displayLayer: on the delegate to override how sample rectangles are calculated; remember to use currentSampleIndex, ignore sampleIndex == 0, and set the layer's bounds
- (void)display;
{
static const CGRect sampleRects[11] = {
{ 0, 0, 38, 47 }, // run
{ 0, 47, 46, 47 },
{ 82, 0, 40, 47 },
{ 122, 0, 30, 47 },
{ 152, 0, 36, 47 },
{ 38, 0, 44, 47 },
{ 188, 0, 42, 47 },
{ 230, 0, 26, 47 },
{ 46, 47, 28, 47 },
{ 74, 47, 28, 47 },
{ 102, 47, 28, 47 },
};
unsigned int idx = [self currentSampleIndex];
if (idx == 0)
return;
self.bounds = CGRectMake(0, 0, sampleRects[idx-1].size.width, sampleRects[idx-1].size.height);
self.contentsRect = CGRectMake(sampleRects[idx-1].origin.x/256.0f, sampleRects[idx-1].origin.y/128.0f, sampleRects[idx-1].size.width/256.0f, sampleRects[idx-1].size.height/128.0f);
}
@end
如果你有任何问题,请不要犹豫。;)
https://stackoverflow.com/questions/11330372
复制相似问题