User prompt
Make the player paint a line when move toward the cursor
User prompt
Make player small
User prompt
Make draw asset small
User prompt
Make player bigger and front of draw asset
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: 19
User prompt
When player moves draw a line by white color
User prompt
make movement of player smoothly forward to the cursor
User prompt
move player horizontal or vertical to the cursor with large distance and stop.
User prompt
Make the player move only 4 direction when click left go left if right go right so on
User prompt
Set draw asset behind player
User prompt
Make the player bigger then draw
User prompt
Please fix the bug: 'Draw is not defined' in or related to this line: 'var draw = new Draw();' Line Number: 65
User prompt
Make player movement by directions right left horizontally and up and down vertically
User prompt
remove draw from screen but let its asset
User prompt
Please fix the bug: 'TypeError: drawGraphics.lineTo is not a function' in or related to this line: 'drawGraphics.lineTo(player.x, player.y);' Line Number: 63
User prompt
Please fix the bug: 'TypeError: drawGraphics.lineTo is not a function' in or related to this line: 'drawGraphics.lineTo(player.x, player.y);' Line Number: 62
User prompt
Please fix the bug: 'TypeError: drawGraphics.moveTo is not a function' in or related to this line: 'drawGraphics.moveTo(player.x, player.y);' Line Number: 60
User prompt
Please fix the bug: 'TypeError: drawGraphics.moveTo is not a function' in or related to this line: 'drawGraphics.moveTo(player.x, player.y);' Line Number: 59
User prompt
Please fix the bug: 'ReferenceError: player is not defined' in or related to this line: 'drawGraphics.moveTo(player.x, player.y);' Line Number: 53
User prompt
Please fix the bug: 'TypeError: drawGraphics.lineStyle is not a function' in or related to this line: 'drawGraphics.lineStyle(2, 0xffd900, 1);' Line Number: 52
User prompt
Please fix the bug: 'TypeError: drawGraphics.setStrokeStyle is not a function' in or related to this line: 'drawGraphics.setStrokeStyle(2, 0xffd900, 1);' Line Number: 52
User prompt
Please fix the bug: 'TypeError: drawGraphics.setStrokeStyle is not a function' in or related to this line: 'drawGraphics.setStrokeStyle(2, 0xffd900, 1);' Line Number: 52
User prompt
Please fix the bug: 'TypeError: drawGraphics.lineStyle is not a function' in or related to this line: 'drawGraphics.lineStyle(2, 0xffd900, 1);' Line Number: 52
User prompt
Please fix the bug: 'ReferenceError: drawGraphics is not defined' in or related to this line: 'drawGraphics.clear();' Line Number: 47
User prompt
Please fix the bug: 'Cannot set properties of undefined (setting 'update')' in or related to this line: 'self.update = function () {' Line Number: 46
/**** * Classes ****/ var Line = Container.expand(function () { var self = Container.call(this); self.graphics = new Graphics(); self.addChild(self.graphics); self.update = function () { self.graphics.clear(); self.graphics.lineStyle(2, 0xFFFFFF, 1); self.graphics.moveTo(0, 0); self.graphics.lineTo(self.parent.targetX - self.parent.x, self.parent.targetY - self.parent.y); }; return self; }); var Player = Container.expand(function () { var self = Container.call(this); var playerGraphics = self.attachAsset('player', { anchorX: 0.5, anchorY: 0.5, scaleX: 1, scaleY: 1 }); self.speed = 5; self.moveRight = function (distance) { self.x += distance; }; self.moveLeft = function (distance) { self.x -= distance; }; self.moveUp = function (distance) { self.y -= distance; }; self.moveDown = function (distance) { self.y += distance; }; return self; }); /**** * 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 = 2048 / 2; player.y = 2732 / 2; game.down = function (x, y, obj) { player.targetX = x; player.targetY = y; }; var line = game.addChild(new Line()); var self = game; self.update = function () { line.x = player.x; line.y = player.y; if (Math.abs(player.targetX - player.x) > player.speed) { if (player.targetX > player.x) { player.moveRight(player.speed); } else { player.moveLeft(player.speed); } } else { player.x = player.targetX; } if (Math.abs(player.targetY - player.y) > player.speed) { if (player.targetY > player.y) { player.moveDown(player.speed); } else { player.moveUp(player.speed); } } else { player.y = player.targetY; } };
===================================================================
--- original.js
+++ change.js
@@ -2,16 +2,15 @@
* Classes
****/
var Line = Container.expand(function () {
var self = Container.call(this);
- var lineGraphics = self.attachAsset('draw', {
- anchorX: 0.5,
- anchorY: 0.5,
- scaleX: 0.5,
- scaleY: 0.5
- });
+ self.graphics = new Graphics();
+ self.addChild(self.graphics);
self.update = function () {
- // line drawing functionality removed due to limitations in the LK game engine
+ self.graphics.clear();
+ self.graphics.lineStyle(2, 0xFFFFFF, 1);
+ self.graphics.moveTo(0, 0);
+ self.graphics.lineTo(self.parent.targetX - self.parent.x, self.parent.targetY - self.parent.y);
};
return self;
});
var Player = Container.expand(function () {
@@ -62,11 +61,9 @@
game.down = function (x, y, obj) {
player.targetX = x;
player.targetY = y;
};
-var line = game.addChildAt(new Line(), 0);
-line.x = 2048 / 2;
-line.y = 2732 / 2;
+var line = game.addChild(new Line());
var self = game;
self.update = function () {
line.x = player.x;
line.y = player.y;