User prompt
import tween and make an example animation ↪💡 Consider importing and using the following plugins: @upit/tween.v1
Code edit (1 edits merged)
Please save this source code
User prompt
Import the tween plugin ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Delete all code
Initial prompt
Plugin Test
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); /**** * Classes ****/ var GameObject = Container.expand(function () { var self = Container.call(this); // Attach a shape asset to the game object var gameObjectGraphics = self.attachAsset('character', { anchorX: 0.5, anchorY: 0.5 }); // Set the initial position of the game object self.x = 1024; self.y = 1366; // This is automatically called every game tick, if the game object is attached! self.update = function () { // Apply a tween animation to the game object tween(self, { x: 500, y: 500 }, { duration: 2000, easing: tween.easeInOut }); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ // Add the game object to the game var gameObject = game.addChild(new GameObject()); // Call the update function of the game object gameObject.update();
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,45 @@
-/****
+/****
+* Plugins
+****/
+var tween = LK.import("@upit/tween.v1");
+
+/****
+* Classes
+****/
+var GameObject = Container.expand(function () {
+ var self = Container.call(this);
+ // Attach a shape asset to the game object
+ var gameObjectGraphics = self.attachAsset('character', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Set the initial position of the game object
+ self.x = 1024;
+ self.y = 1366;
+ // This is automatically called every game tick, if the game object is attached!
+ self.update = function () {
+ // Apply a tween animation to the game object
+ tween(self, {
+ x: 500,
+ y: 500
+ }, {
+ duration: 2000,
+ easing: tween.easeInOut
+ });
+ };
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
backgroundColor: 0x000000
-});
\ No newline at end of file
+});
+
+/****
+* Game Code
+****/
+// Add the game object to the game
+var gameObject = game.addChild(new GameObject());
+// Call the update function of the game object
+gameObject.update();
\ No newline at end of file