egret-docs-master/Engine3D/Egret3DAnimation/sprite/README.md

24 lines
1.2 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## 精灵表
精灵表是2D常用的一种切帧动画形式。大概来说就是将动画的每一帧作为一个完整的图像将所有不同的帧集中到一个大的透明图像中每一帧都有其对应的起始坐标点及其宽度、高度这张大的透明图像称为精灵表纹理集。这样在播放动画时只需要在不同的时间帧在精灵表纹理集中取该时间帧对应的动画帧纹理并显示出来。
## 呈现UV精灵表动画
// 使用uv 帧动画
protected uvSpriteAnimation() {
var mat: egret3d.TextureMaterial = new egret3d.TextureMaterial();
mat.repeat = true;
var plane: egret3d.Mesh = new egret3d.Mesh(new egret3d.PlaneGeometry(1000, 1000, 10, 10, 1, 1), mat);
this.view.addChild3D(plane);
plane.y = 10;
var uvSpriteSheetMethod: egret3d.UVSpriteSheetMethod = new egret3d.UVSpriteSheetMethod(34, 6, 6, 3.0);
mat.diffusePass.addMethod(uvSpriteSheetMethod);
uvSpriteSheetMethod.start(true);
mat.diffuseTexture = this.queueLoader.getAsset("resource/doc/test1.png");
}
本例所用的精灵表纹理集图片为:
![image](575cd8fe67128.png)
![](Img_6.gif)