User prompt
Fix Bug: 'ReferenceError: joystick is not defined' in this line: 'joystick.visible = false;' Line Number: 61
User prompt
Fix Bug: 'ReferenceError: joystick is not defined' in this line: 'initialJoystickPos = event.getLocalPosition(joystick.parent);' Line Number: 70
User prompt
Fix Bug: 'ReferenceError: joystick is not defined' in this line: 'joystick.visible = true;' Line Number: 57
User prompt
Fix Bug: 'ReferenceError: joystick is not defined' in this line: 'var pos = event.getLocalPosition(joystick.parent);' Line Number: 56
User prompt
Fix Bug: 'Uncaught ReferenceError: joystick is not defined' in this line: 'joystick.on('down', function (obj) {' Line Number: 64
User prompt
make joystick being a combination of 2 assets. JoystickBase and JoystickStick. So keep joystick base on the position of joystick but update joystickstick based on where player's finger on the screen, but on the radius from initial position.
User prompt
Start with a score 0 and update it as integer instead of parsing text
User prompt
show player score on the middle
User prompt
Make player size 300 x 300 initially.
User prompt
do not allow player move away from world
User prompt
spawn 100 foes
User prompt
make a bckground behind everything
User prompt
make seamless a background tiling and world size 16384 x 16384
User prompt
Fix Bug: 'Uncaught TypeError: Graphics is not a constructor' in this line: 'var blobGraphics = new Graphics();' Line Number: 3
User prompt
make blob and foes are circles
User prompt
make a joystick stick to a screen, do not move it durion blob movement
User prompt
make a camera follow blob
User prompt
do not updatejoystick position during move, only calculate velocity for blob
User prompt
calculate movement based on initial joystick position
User prompt
make consistante move and down event for joystick
User prompt
make a joystickwork immidiatly on first press screen
User prompt
make a joystick calculation based on it position
User prompt
make a joystick appear on a position of press
User prompt
make a joystick appear on the screen press
User prompt
make a joustick control
var Blob = Container.expand(function () { var self = Container.call(this); var blobGraphics = self.createAsset('blob', 'Blob Graphics', 0.5, 0.5); self.speed = 5; self.vx = 0; self.vy = 0; self.move = function () { self.x = Math.max(0, Math.min(self.x + self.vx, 16384)); self.y = Math.max(0, Math.min(self.y + self.vy, 16384)); }; self.expand = function () {}; }); var Foe = Container.expand(function () { var self = Container.call(this); var foeGraphics = self.createAsset('foe', 'Foe Graphics', 0.5, 0.5); self.speed = 3; self.move = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); self.worldWidth = 16384; self.worldHeight = 16384; var background = self.createAsset('background', 'Background', 0, 0); background.width = self.worldWidth; background.height = self.worldHeight; self.addChildAt(background, 0); var blobs = []; var foes = []; var isGameOver = false; var dragNode = null; var playerBlob = self.addChild(new Blob()); playerBlob.x = self.worldWidth / 2; playerBlob.y = self.worldHeight / 2; playerBlob.width = 300; playerBlob.height = 300; blobs.push(playerBlob); for (var i = 0; i < 100; i++) { var foe = self.addChild(new Foe()); foe.x = Math.random() * self.worldWidth; foe.y = Math.random() * self.worldHeight; foes.push(foe); } var joystickBase = LK.gui.bottomRight.createAsset('joystickBase', 'Joystick Base', 1, 1); var joystickStick = joystickBase.createAsset('joystickStick', 'Joystick Stick', 0.5, 0.5); joystickBase.visible = true; joystickStick.visible = false; var score = 0; var scoreTxt = new Text2(score.toString(), { size: 150, fill: '#ffffff' }); scoreTxt.anchor.set(.5, .5); LK.gui.center.addChild(scoreTxt); stage.on('down', function (obj) { var event = obj.event; var pos = event.getLocalPosition(joystickBase.parent); joystickBase.visible = true; joystickDrag = true; }); stage.on('up', function (obj) { joystickBase.visible = false; }); var joystickDrag = false; joystickBase.on('down', function (obj) { joystickDrag = true; }); var initialJoystickPos = null; stage.on('down', function (obj) { var event = obj.event; initialJoystickPos = event.getLocalPosition(joystickBase.parent); joystickDrag = true; }); stage.on('move', function (obj) { if (joystickDrag) { var event = obj.event; var pos = event.getLocalPosition(joystickBase.parent); var dx = pos.x - initialJoystickPos.x; var dy = pos.y - initialJoystickPos.y; var distance = Math.sqrt(dx * dx + dy * dy); var angle = Math.atan2(dy, dx); playerBlob.vx = Math.cos(angle) * playerBlob.speed; playerBlob.vy = Math.sin(angle) * playerBlob.speed; joystickStick.x = Math.min(distance, joystickBase.width / 2) * Math.cos(angle); joystickStick.y = Math.min(distance, joystickBase.height / 2) * Math.sin(angle); joystickStick.visible = true; } }); stage.on('up', function (obj) { joystickDrag = false; playerBlob.vx = 0; playerBlob.vy = 0; joystickStick.visible = false; joystickStick.x = 0; joystickStick.y = 0; }); LK.on('tick', function () { for (var i = 0; i < blobs.length; i++) { blobs[i].move(); } for (var i = 0; i < foes.length; i++) { foes[i].move(); } for (var i = 0; i < blobs.length; i++) { for (var j = 0; j < foes.length; j++) { if (blobs[i].intersects(foes[j])) { blobs[i].expand(); foes[j].destroy(); foes.splice(j, 1); score += 1; scoreTxt.setText(score.toString()); } } } if (blobs.length == 0) { isGameOver = true; } if (isGameOver) { LK.effects.flashScreen(0xff0000, 1000); LK.showGameOver(); } self.x = -Math.min(Math.max(playerBlob.x, 2048 / 2), self.worldWidth - 2048 / 2) + 2048 / 2; self.y = -Math.min(Math.max(playerBlob.y, 2732 / 2), self.worldHeight - 2732 / 2) + 2732 / 2; }); });
===================================================================
--- original.js
+++ change.js
@@ -57,9 +57,9 @@
joystickBase.visible = true;
joystickDrag = true;
});
stage.on('up', function (obj) {
- joystick.visible = false;
+ joystickBase.visible = false;
});
var joystickDrag = false;
joystickBase.on('down', function (obj) {
joystickDrag = true;