User prompt
Set player position at bottom
User prompt
Add speed to player
User prompt
Makae it move large area and stop
User prompt
Make the player follow the cursor
User prompt
make player move large area
User prompt
if the button clicked in the screen move the player to cursor smoothly by short distance then stop.
User prompt
make player move to the clicked direction toward the cursor smoothly by short distance then stop
User prompt
make player follow cursor smoothly when click in the current direction on the screen.
User prompt
Move player by click horizontal or vertical
User prompt
Make player move toward the cursor smoothly
User prompt
Add movement by click in any direction right or down or left or up to follow cursor smoothly
User prompt
Please fix the bug: 'TypeError: lineGraphics.lineTo is not a function' in or related to this line: 'lineGraphics.lineTo(player.lastX, player.lastY);' Line Number: 35
User prompt
Please fix the bug: 'TypeError: lineGraphics.moveTo is not a function' in or related to this line: 'lineGraphics.moveTo(player.x, player.y);' Line Number: 33
User prompt
Please fix the bug: 'TypeError: lineGraphics.lineStyle is not a function' in or related to this line: 'lineGraphics.lineStyle(2, 0xffffff, 1);' Line Number: 33
User prompt
Make line the line of player when he moves
User prompt
Scale it more
User prompt
Scale player a bit
User prompt
Remove draw from game
User prompt
Reposition the player front of draw asset and make the asset draw smaller
User prompt
Make the player move smooth by hold on it
User prompt
Make the player front of draw asset
User prompt
Please fix the bug: 'TypeError: self.graphics.lineTo is not a function' in or related to this line: 'self.graphics.lineTo(self.parent.targetX - self.parent.x, self.parent.targetY - self.parent.y);' Line Number: 22
User prompt
Please fix the bug: 'TypeError: self.graphics.moveTo is not a function' in or related to this line: 'self.graphics.moveTo(0, 0);' Line Number: 21
User prompt
Please fix the bug: 'TypeError: self.graphics.lineStyle is not a function' in or related to this line: 'self.graphics.lineStyle(2, 0xFFFFFF, 1);' Line Number: 20
User prompt
Please fix the bug: 'Graphics is not a constructor' in or related to this line: 'self.graphics = new Graphics();' Line Number: 13
/**** * Classes ****/ var Draw = Container.expand(function () { var self = Container.call(this); var drawGraphics = self.attachAsset('draw', { anchorX: 0.5, anchorY: 0.5 }); self.update = function () { drawGraphics.clear(); // There is no lineStyle method in LK engine. We can set the color of the shape directly when initializing it. self.x = player.x; self.y = player.y; }; }); 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; // 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.lastX - player.x; lineGraphics.height = player.lastY - player.y; }; }); /**** * 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(LK.getAsset('player', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2 - 100, scaleX: 1.5, scaleY: 1.5 })); player.interactive = true; player.on('mousedown', onDragStart).on('touchstart', onDragStart).on('mouseup', onDragEnd).on('mouseupoutside', onDragEnd).on('touchend', onDragEnd).on('touchendoutside', onDragEnd).on('mousemove', onDragMove).on('touchmove', onDragMove); function onDragStart(event) { this.data = event.data; this.alpha = 0.5; this.dragging = true; } function onDragEnd() { this.alpha = 1; this.dragging = false; this.data = null; } var line = game.addChild(new Line()); function onDragMove() { if (this.dragging) { var newPosition = this.data.getLocalPosition(this.parent); this.lastX = this.x; this.lastY = this.y; this.x += (newPosition.x - this.x) * 0.05; this.y += (newPosition.y - this.y) * 0.05; if (Math.abs(newPosition.x - this.x) < 5 && Math.abs(newPosition.y - this.y) < 5) { this.dragging = false; } } } ;
===================================================================
--- original.js
+++ change.js
@@ -73,10 +73,10 @@
if (this.dragging) {
var newPosition = this.data.getLocalPosition(this.parent);
this.lastX = this.x;
this.lastY = this.y;
- this.x += (newPosition.x - this.x) * 0.2;
- this.y += (newPosition.y - this.y) * 0.2;
+ this.x += (newPosition.x - this.x) * 0.05;
+ this.y += (newPosition.y - this.y) * 0.05;
if (Math.abs(newPosition.x - this.x) < 5 && Math.abs(newPosition.y - this.y) < 5) {
this.dragging = false;
}
}