فهرست منبع

Added euler rotation example

Björn Ritzl 11 ماه پیش
والد
کامیت
ae8d3316c0

+ 6 - 0
examples/_main/loader.go

@@ -424,3 +424,9 @@ embedded_components {
   data: "collection: \"/examples/material/noise/noise.collection\"\n"
   ""
 }
+embedded_components {
+  id: "animation/euler_rotation"
+  type: "collectionproxy"
+  data: "collection: \"/examples/animation/euler_rotation/euler_rotation.collection\"\n"
+  ""
+}

+ 1 - 1
examples/_main/menu.gui_script

@@ -104,7 +104,7 @@ function init(self)
 	self.index["factory"] = { "basic", "bullets", "dynamic" }
 	self.index["movement"] = { "simple_move", "follow", "move_to", "move_forward", "movement_speed", "look_at" }
 	self.index["physics"] = { "dynamic", "kinematic", "raycast", "trigger", "hinge_joint", "pendulum", "knockback"}
-	self.index["animation"] = { "spinner", "flipbook", "chained_tween", "basic_tween", "spine", "cursor", "easing" }
+	self.index["animation"] = { "euler_rotation", "spinner", "flipbook", "chained_tween", "basic_tween", "spine", "cursor", "easing" }
 	self.index["gui"] = {
 		"button", "stencil", "load_texture",
 		"progress", "pointer_over", "color",

+ 30 - 0
examples/animation/euler_rotation/euler_rotation.collection

@@ -0,0 +1,30 @@
+name: "euler_rotation"
+scale_along_z: 0
+embedded_instances {
+  id: "go"
+  data: "components {\n"
+  "  id: \"euler_rotation\"\n"
+  "  component: \"/examples/animation/euler_rotation/euler_rotation.script\"\n"
+  "}\n"
+  "embedded_components {\n"
+  "  id: \"sprite\"\n"
+  "  type: \"sprite\"\n"
+  "  data: \"default_animation: \\\"spinner\\\"\\n"
+  "material: \\\"/builtins/materials/sprite.material\\\"\\n"
+  "textures {\\n"
+  "  sampler: \\\"texture_sampler\\\"\\n"
+  "  texture: \\\"/assets/sprites.atlas\\\"\\n"
+  "}\\n"
+  "\"\n"
+  "}\n"
+  ""
+  position {
+    x: 360.0
+    y: 360.0
+  }
+  scale3 {
+    x: 0.5
+    y: 0.5
+    z: 0.5
+  }
+}

+ 5 - 0
examples/animation/euler_rotation/euler_rotation.md

@@ -0,0 +1,5 @@
+---
+title: Euler Rotation
+brief: This example shows how to animate the rotation of a game object using the euler game object property.
+scripts: euler_rotation.script
+---

+ 4 - 0
examples/animation/euler_rotation/euler_rotation.script

@@ -0,0 +1,4 @@
+function init(self)
+	-- rotate clockwise one full revolution in two seconds
+	go.animate(".", "euler.z", go.PLAYBACK_LOOP_FORWARD, -360, go.EASING_LINEAR, 2)
+end