有没有更好的方法来加载大动画?

发布于 2024-07-24 09:24:40 字数 370 浏览 8 评论 0原文

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

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" );

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

Maybe not really big, but a hundred frames or something. Is the only way to load it in by making an array and loading each image individually?

load_image() is a function I made which loads the images and converts their 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" );

Seems like their should be a better way.. at least I hope.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

九公里浅绿 2024-07-31 09:24:40

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

A common technique is spritesheets, in which a single, large image is divided into a grid of cells, with each cell containing one frame of an animation. Often, all animation frames for any game entity are placed on a single, sometimes huge, sprite sheet.

傲影 2024-07-31 09:24:40

也许可以使用一个实用函数来简化您的加载,该函数为循环的每次迭代构建一个文件名:

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);
    }
}

maybe simplify your loading with a utility function that builds a filename for each iteration of a loop:

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);
    }
}
悲念泪 2024-07-31 09:24:40

不要作为网格加载,而是将所有帧堆叠在一个垂直条中(同一图像)。 然后你只需要知道每帧有多少行,你就可以设置一个指向帧行偏移的指针。 您最终仍然拥有可以直接显示或简单地分解成单独图像的连续扫描线。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文