有没有更好的方法来加载大动画?
也许不是很大,但有一百帧之类的。 是通过创建数组并单独加载每个图像来加载它的唯一方法吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
一种常见的技术是精灵表,其中单个大图像被划分为单元格网格,每个单元格包含一帧动画。 通常,任何游戏实体的所有动画帧都放置在单个(有时是巨大的)精灵表上。
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.
也许可以使用一个实用函数来简化您的加载,该函数为循环的每次迭代构建一个文件名:
maybe simplify your loading with a utility function that builds a filename for each iteration of a loop:
不要作为网格加载,而是将所有帧堆叠在一个垂直条中(同一图像)。 然后你只需要知道每帧有多少行,你就可以设置一个指向帧行偏移的指针。 您最终仍然拥有可以直接显示或简单地分解成单独图像的连续扫描线。
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.