最近看到EaselJS相关内容,网上资料并不是很多,翻译一下原文档与个人理解,错误请留言,转载请标明转载出处。
Encapsulates the properties and methods associated with a sprite sheet. A sprite sheet is a series of images (usually animation frames) combined into a larger image (or images). For example, an animation consisting of eight 100x100 images could be combined into a single 400x200 sprite sheet (4 frames across by 2 high).
The data passed to the SpriteSheet constructor defines three critical pieces of information:
The image or images to use.The positions of individual image frames. This data can be represented in one of two ways: As a regular grid of sequential, equal-sized frames, or as individually defined, variable sized frames arranged in an irregular (non-sequential) fashion.Likewise, animations can be represented in two ways: As a series of sequential frames, defined by a start and end frame [0,3], or as a list of frames [0,1,2,3].一个精灵表是一系列图像(通常是动画帧)合并成一个大的图像。例如一个动画有8个100*100的图片组成,可以组成一个400*200的精灵表(4帧跨越2个高度)。
被传送给精灵表构造器的数据需要定义3个关键部分:
1.使用的图像
2.单独图像帧的位置,数据可以通过两种方式来表示:1:作为一个连续的规则网格,相同大小的帧;2:被设置在不规则(不连续)框架中的单独定义可变大小的帧
3.同样的动画可通过两种方式来表达:1:一系列连续的帧,通过开始结束帧定义[0,3];2:一系列帧[0,1,2,3]
speed frequency Example实例
To define a simple sprite sheet, with a single image "sprites.jpg" arranged in a regular 50x50 grid with two animations, "run" looping from frame 0-4 inclusive, and "jump" playing from frame 5-8 and sequencing back to run:
通过布满50*50顺序网格的单一图像来定义一个简单精灵列表,有两个动画,0-4帧为奔跑,5-8帧为跳跃,之后接着奔跑
var data = { images: ["sprites.jpg"], frames: {width:50, height:50}, animations: {run:[0,4], jump:[5,8,"run"]} }; var spriteSheet = new createjs.SpriteSheet(data); var animation = new createjs.Sprite(spriteSheet, "run");
Displays a frame or sequence of frames (ie. an animation) from a SpriteSheet instance. A sprite sheet is a series of images (usually animation frames) combined into a single image. For example, an animation consisting of 8 100x100 images could be combined into a 400x200 sprite sheet (4 frames across by 2 high). You can display individual frames, play frames as an animation, and even sequence animations together.
翻译:由SpriteSheet实例显示一个帧或帧序列,一个精灵列表是一系列图片(通常为动画帧)组成的单一图片,例如一个由8个100*100图像组成的动画可以被组成一个400*200的精灵序列(4帧跨越两个高度)。你可以作为动画来显示帧,播放帧,即时是在一块的有序帧
See the SpriteSheet class for more information on setting up frames and animations.
通过阅读SpriteSheet类来获取更多建立帧和动画的信息
转载于:https://www.cnblogs.com/Eudora/p/4103257.html
相关资源:数据结构—成绩单生成器