且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

什么是阅读Java中的精灵表的***方法是什么?

更新时间:2023-01-13 13:23:26

我目前使用的存储精灵作为(可选动画)的集合由一个简单的精灵编辑器生成的XML文件构成,这是又一个框架的集合或细胞。帧存储每帧信息一样的x和y在片,细胞的宽度和高度的帧的偏移,以及任何变换(调整大小/旋转/色调/等等)。姿势店单独的帧和动画信息(速度,例如),和一个姿势的名字更容易识别它们在程序(hero.pose = sprite.pose [standing_right])。精灵作为文档根持有几个姿势,如姿势每个面对的方向。

I currently use XML files generated by a simple sprite editor that store the sprite as a collection of (optionally animated) poses, which are in turn a collection of frames or cells. Frames store per-frame information like the x and y offset of the frame in sheet, cell width and height, and any transformation (resize/rotation/hue/etc.). Poses store individual frames and animation information (speed, for example), and a pose name to easily identify them in the program (hero.pose = sprite.pose["standing_right"]). Sprites serve as a document root to hold several poses, such as a pose for each facing direction.

一个弹性较差的替代我先前用来为指定的固定尺寸的细胞和表和计算基于这些值的帧偏移和大小(例如,宽度始终32像素,所以第三子画面是在32 * 2)。后来我开始在文件名中指定这些维度(如sprite_name_32x64.png)对于不适合固定单元尺寸的精灵。我喜欢新的方法较多,尤其是一个简单的编辑器,填补最为看重的,我和允许我使用精灵作为其他精灵的模板。

A less flexible alternative I used earlier was to specify fixed sizes for cells and sheets and calculate frame offsets and sizes based on these values (e.g. width is always 32 pixels, so third sprite is at 32 * 2). Later I started specifying these dimensions in the file name (e.g. sprite_name_32x64.png) for sprites that don't fit the fixed cell dimensions. I like the new approach more, especially with a simplistic editor that fills most values for me and allows me to use sprites as templates for other sprites.

我使用存储在PNG图像的alpha和透明度的信息直接,所以我不用担心其他地方存放,但其他的方法是将挑选每精灵的固定值和存储的地方,使用的最左端像素的如果你知道它总是空的姿势,如果你使用的,精灵面具使用特定的调色板项,或你有什么。

I use the alpha and transparency information stored in PNG images directly so I don't need to worry about storing it elsewhere, although other approaches would be to pick a fixed value per sprite and store somewhere, use the leftmost pixel in the pose if you know it's always empty, use a specific palette entry if you're using those, sprite masks, or what have you.