Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

fix(examples): sprite-animation spritesheet demo + @uuid texture refs

esenginef46cede3b7ee
diff --git a/examples/sprite-animation/assets/animations/coin.esanim b/examples/sprite-animation/assets/animations/coin.esanim
new file mode 100644
index 000000000..47626c611
--- /dev/null
+++ b/examples/sprite-animation/assets/animations/coin.esanim
@@ -0,0 +1,41 @@
+{
+ "version": "1.2",
+ "type": "animation-clip",
+ "fps": 12,
+ "loop": true,
+ "sheet": {
+ "texture": "@uuid:25e16a82-b500-46c3-8276-36d5f4a0eb15",
+ "cellWidth": 64,
+ "cellHeight": 64,
+ "margin": 0,
+ "spacing": 0,
+ "pageWidth": 512,
+ "pageHeight": 64
+ },
+ "frames": [
+ {
+ "cell": 0
+ },
+ {
+ "cell": 1
+ },
+ {
+ "cell": 2
+ },
+ {
+ "cell": 3
+ },
+ {
+ "cell": 4
+ },
+ {
+ "cell": 5
+ },
+ {
+ "cell": 6
+ },
+ {
+ "cell": 7
+ }
+ ]
+}
diff --git a/examples/sprite-animation/assets/animations/coin.esanim.meta b/examples/sprite-animation/assets/animations/coin.esanim.meta
new file mode 100644
index 000000000..451958b54
--- /dev/null
+++ b/examples/sprite-animation/assets/animations/coin.esanim.meta
@@ -0,0 +1,6 @@
+{
+ "uuid": "54b9d360-6d0c-4919-b36e-13377340c98b",
+ "version": "2.0",
+ "type": "animclip",
+ "importer": {}
+}
diff --git a/examples/sprite-animation/assets/animations/idle.esanim b/examples/sprite-animation/assets/animations/idle.esanim
index 65f2e8012..ce8c846da 100644
--- a/examples/sprite-animation/assets/animations/idle.esanim
+++ b/examples/sprite-animation/assets/animations/idle.esanim
@@ -3,19 +3,19 @@
"loop": true,
"frames": [
{
- "texture": "e43a0ed9-50e9-46d8-b1db-da1c549590a8",
+ "texture": "@uuid:e43a0ed9-50e9-46d8-b1db-da1c549590a8",
"duration": 0.4
},
{
- "texture": "e9785b6d-6f6e-4dfb-aeed-66d39e5671e4",
+ "texture": "@uuid:e9785b6d-6f6e-4dfb-aeed-66d39e5671e4",
"duration": 0.2
},
{
- "texture": "36bf91fa-66a4-449b-8a7c-7bc261a04732",
+ "texture": "@uuid:36bf91fa-66a4-449b-8a7c-7bc261a04732",
"duration": 0.2
},
{
- "texture": "92b3d54a-dd57-40f8-87b7-43e93d6b6a26",
+ "texture": "@uuid:92b3d54a-dd57-40f8-87b7-43e93d6b6a26",
"duration": 0.35
}
]
diff --git a/examples/sprite-animation/assets/animations/walk.esanim b/examples/sprite-animation/assets/animations/walk.esanim
index 9ff46f5d9..c6ebcd9ae 100644
--- a/examples/sprite-animation/assets/animations/walk.esanim
+++ b/examples/sprite-animation/assets/animations/walk.esanim
@@ -3,16 +3,16 @@
"loop": true,
"frames": [
{
- "texture": "a354adf4-afc0-49a2-8cad-8c8f40d3d669"
+ "texture": "@uuid:a354adf4-afc0-49a2-8cad-8c8f40d3d669"
},
{
- "texture": "586f71d5-05fd-4abc-b534-d81a042382b4"
+ "texture": "@uuid:586f71d5-05fd-4abc-b534-d81a042382b4"
},
{
- "texture": "ca5ce245-b0d4-46f3-b8f0-055d30f82800"
+ "texture": "@uuid:ca5ce245-b0d4-46f3-b8f0-055d30f82800"
},
{
- "texture": "be2aabee-879f-4a7b-923b-e7f793e4d56f"
+ "texture": "@uuid:be2aabee-879f-4a7b-923b-e7f793e4d56f"
}
]
}
\ No newline at end of file
diff --git a/examples/sprite-animation/assets/scenes/coins.esscene b/examples/sprite-animation/assets/scenes/coins.esscene
new file mode 100644
index 000000000..1873705ca
--- /dev/null
+++ b/examples/sprite-animation/assets/scenes/coins.esscene
@@ -0,0 +1,179 @@
+{
+ "version": "1.0",
+ "name": "Coins",
+ "entities": [
+ {
+ "id": 0,
+ "name": "Camera",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": { "position": { "x": 0, "y": 0, "z": 10 } }
+ },
+ {
+ "type": "Camera",
+ "data": { "projectionType": 1, "orthoSize": 300, "isActive": true, "priority": 0 }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 1,
+ "name": "Backdrop",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": { "position": { "x": 0, "y": 0, "z": -5 } }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": { "x": 820, "y": 620 },
+ "color": { "r": 0.11, "g": 0.13, "b": 0.19, "a": 1 },
+ "layer": 0
+ }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 2,
+ "name": "Coin L",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": { "position": { "x": -280, "y": 0, "z": 0 } }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": { "x": 100, "y": 100 },
+ "texture": "assets/textures/coin.png",
+ "uvOffset": { "x": 0, "y": 0 },
+ "uvScale": { "x": 0.125, "y": 1 },
+ "layer": 5
+ }
+ },
+ {
+ "type": "SpriteAnimator",
+ "data": { "clip": "assets/animations/coin.esanim", "speed": 0.8 }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 3,
+ "name": "Coin ML",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": { "position": { "x": -145, "y": 0, "z": 0 } }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": { "x": 130, "y": 130 },
+ "texture": "assets/textures/coin.png",
+ "uvOffset": { "x": 0, "y": 0 },
+ "uvScale": { "x": 0.125, "y": 1 },
+ "layer": 5
+ }
+ },
+ {
+ "type": "SpriteAnimator",
+ "data": { "clip": "assets/animations/coin.esanim", "speed": 1.1 }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 4,
+ "name": "Coin Hero",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": { "position": { "x": 0, "y": 0, "z": 0 } }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": { "x": 164, "y": 164 },
+ "texture": "assets/textures/coin.png",
+ "uvOffset": { "x": 0, "y": 0 },
+ "uvScale": { "x": 0.125, "y": 1 },
+ "layer": 6
+ }
+ },
+ {
+ "type": "SpriteAnimator",
+ "data": { "clip": "assets/animations/coin.esanim", "speed": 1 }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 5,
+ "name": "Coin MR",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": { "position": { "x": 145, "y": 0, "z": 0 } }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": { "x": 130, "y": 130 },
+ "texture": "assets/textures/coin.png",
+ "uvOffset": { "x": 0, "y": 0 },
+ "uvScale": { "x": 0.125, "y": 1 },
+ "layer": 5
+ }
+ },
+ {
+ "type": "SpriteAnimator",
+ "data": { "clip": "assets/animations/coin.esanim", "speed": 1.25 }
+ }
+ ],
+ "visible": true
+ },
+ {
+ "id": 6,
+ "name": "Coin R",
+ "parent": null,
+ "children": [],
+ "components": [
+ {
+ "type": "Transform",
+ "data": { "position": { "x": 280, "y": 0, "z": 0 } }
+ },
+ {
+ "type": "Sprite",
+ "data": {
+ "size": { "x": 100, "y": 100 },
+ "texture": "assets/textures/coin.png",
+ "uvOffset": { "x": 0, "y": 0 },
+ "uvScale": { "x": 0.125, "y": 1 },
+ "layer": 5
+ }
+ },
+ {
+ "type": "SpriteAnimator",
+ "data": { "clip": "assets/animations/coin.esanim", "speed": 0.65 }
+ }
+ ],
+ "visible": true
+ }
+ ]
+}
diff --git a/examples/sprite-animation/assets/scenes/coins.esscene.meta b/examples/sprite-animation/assets/scenes/coins.esscene.meta
new file mode 100644
index 000000000..1ed7a7867
--- /dev/null
+++ b/examples/sprite-animation/assets/scenes/coins.esscene.meta
@@ -0,0 +1,8 @@
+{
+ "uuid": "db1f9ab8-a857-44ee-b388-7c374e35472b",
+ "version": "2.0",
+ "type": "scene",
+ "importer": {
+ "autoMigrate": true
+ }
+}
diff --git a/examples/sprite-animation/assets/textures/coin.png b/examples/sprite-animation/assets/textures/coin.png
new file mode 100644
index 000000000..cd0b19c2c
Binary files /dev/null and b/examples/sprite-animation/assets/textures/coin.png differ
diff --git a/examples/sprite-animation/assets/textures/coin.png.meta b/examples/sprite-animation/assets/textures/coin.png.meta
new file mode 100644
index 000000000..b7e1f9d28
--- /dev/null
+++ b/examples/sprite-animation/assets/textures/coin.png.meta
@@ -0,0 +1,17 @@
+{
+ "uuid": "25e16a82-b500-46c3-8276-36d5f4a0eb15",
+ "version": "2.0",
+ "type": "texture",
+ "importer": {
+ "maxSize": 2048,
+ "filterMode": "linear",
+ "wrapMode": "clamp",
+ "premultiplyAlpha": false,
+ "sliceBorder": {
+ "left": 0,
+ "right": 0,
+ "top": 0,
+ "bottom": 0
+ }
+ }
+}