User prompt
Add @upit/tween.v1 to the game code if that help player go to cursor than add it. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
Make player go to the cursor by lage distance and moving smoothly to it. ↪💡 Consider importing and using the following plugins: @upit/tween.v1
User prompt
remove what's holding player from moving small distance to the cursor when clicked
User prompt
Make vertical and horizontal movement for the player to move by small distance to the cursor on the screen.
User prompt
Add player to the game add line to the game make it small
User prompt
Remove player and its movments from game
User prompt
Remove player from game
User prompt
change plqyer position to the right
User prompt
If cursor on the screen move player to the clicked point if not clicked don't move it.
User prompt
Make player teleport to cursor
User prompt
If player clicked by cursor make it follow it to any of the 4 directions movments
User prompt
Add movement to the player right left up down
User prompt
Remove all movments of player
User prompt
If the button of the mouse clicked on the player constrain player with it
User prompt
Hold cursor on the player to drag it
User prompt
Make player move by drage
User prompt
Make player go to the direction where the clicked point
User prompt
if player moved draw by line
User prompt
player must go to cursor clicked point
User prompt
Move player to the left if i click left and same for up and right and down
Code edit (1 edits merged)
Please save this source code
User prompt
make it up a bit
User prompt
Set player position at bottom
User prompt
Add speed to player
User prompt
Makae it move large area and stop
/**** * Classes ****/ var Line = Container.expand(function () { var self = Container.call(this); var lineGraphics = self.attachAsset('line', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { lineGraphics.clear(); self.x = player.x; self.y = player.y; lineGraphics.width = player.x - player.lastX; lineGraphics.height = player.y - player.lastY; }; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5 }); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000 }); /**** * Game Code ****/ var background = game.addChild(LK.getAsset('maze1', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 })); background.scale.x = game.width / background.width; background.scale.y = game.height / background.height; var player = game.addChild(new Player()); player.x = game.width / 2; player.y = game.height / 2; var line = game.addChild(new Line()); line.width = 1; line.height = 1; ;
===================================================================
--- original.js
+++ change.js
@@ -10,13 +10,19 @@
self.update = function () {
lineGraphics.clear();
self.x = player.x;
self.y = player.y;
- // There is no lineTo method in LK engine. We can set the width and height of the shape directly when initializing it.
lineGraphics.width = player.x - player.lastX;
lineGraphics.height = player.y - player.lastY;
};
});
+var Player = Container.expand(function () {
+ var self = Container.call(this);
+ var playerGraphics = self.attachAsset('player', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+});
/****
* Initialize Game
****/
@@ -34,6 +40,11 @@
y: 2732 / 2
}));
background.scale.x = game.width / background.width;
background.scale.y = game.height / background.height;
+var player = game.addChild(new Player());
+player.x = game.width / 2;
+player.y = game.height / 2;
var line = game.addChild(new Line());
+line.width = 1;
+line.height = 1;
;
\ No newline at end of file