1

也许不是很大,但有一百帧之类的。是通过制作一个数组并单独加载每个图像来加载它的唯一方法吗?

load_image() 是我制作的一个函数,它加载图像并转换它们的 BPP。

expl[0] = load_image( "explode1.gif" );
expl[1] = load_image( "explode2.gif" );
expl[2] = load_image( "explode3.gif" );
expl[3] = load_image( "explode4.gif" );
...
expl[99] = load_image( "explode100.gif" );

似乎他们应该是一个更好的方法..至少我希望。

4

3 回答 3

1

也许使用为循环的每次迭代构建文件名的实用程序函数来简化您的加载:

LoadAnimation(char* isFileBase, int numFrames)
{
    char szFileName[255];
    for(int i = 0; i < numFrames; i++)
    {
       // append the frame number and .gif to the file base to get the filename
       sprintf(szFileName, "%s%d.gif", isFileBase, i);
       expl[i] = load_image(szFileName);
    }
}
于 2009-06-12T17:09:45.143 回答
1

一种常见的技术是 spritesheets,其中将单个大图像划分为单元格网格,每个单元格包含一帧动画。通常,任何游戏实体的所有动画帧都放置在一个单独的、有时是巨大的精灵表上。

于 2009-06-12T17:13:04.027 回答
1

Instead of loading as a grid, stack all the frames in one vertical strip (same image). Then you only need to know how many rows per frame and you can set a pointer to the frame row offset. You end up still having contiguous scan lines that can be displayed directly or trivially chewed off into separate images.

于 2009-06-13T02:34:03.133 回答