User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'length')' in this line: 'stage.on('move', function (obj) {' Line Number: 126
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'self.createAsset('powerBar', 'Wind power bar display', 0, 0.5);' Line Number: 15
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'self.createAsset('powerBar', 'Wind power bar display', 0, 0.5);' Line Number: 14
User prompt
Fix Bug: 'Uncaught TypeError: Cannot read properties of undefined (reading 'createAsset')' in this line: 'self.createAsset('powerBar', 'Wind power bar display', 0, 0.5);' Line Number: 14
User prompt
Show the asset
var RestartButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.createAsset('restartButton', 'Restart button', 0.5, 0.5); self.x = 2048 / 2; self.y = 2732 - 200; buttonGraphics.on('down', function () { LK.showGameOver(); }); }); var PowerBar = Container.expand(function () {}); var WindPowerBar = PowerBar.expand(function () { var self = PowerBar.call(this); var self = PowerBar.call(this); self.createAsset('powerBar', 'Wind power bar display', 0, 0.5); var windLabel = new Text2('Wind', { size: 400, fill: "#ffffff", align: 'center' }); windLabel.x = self.width / 2; windLabel.y = -self.height; self.addChild(windLabel); self.y = 2732 - 200; }); var Hand = Container.expand(function () { var self = Container.call(this); self.move = function (position, stone) { self.x = position.x; if (!stone.isLaunched) { stone.x = self.x; } }; var handGraphics = self.createAsset('hand', 'Moving hand at the bottom', 0.5, 0.5); self.x = 0; self.y = 2732 - handGraphics.height / 2; self.direction = 1; self.speed = 5; self.visible = true; }); var Stone = Container.expand(function () { var self = Container.call(this); self.launch = function (hand, power) { self.x = hand.x; self.y = hand.y; self.direction = -Math.PI / 2; self.launchPower = power * 0.48; self.speed = self.launchPower; self.isLaunched = true; self.distanceTraveled = 0; LK.setScore(0); }; var stoneGraphics = self.createAsset('stone', 'Stone for ricochet', .5, .5); self.speed = 0; self.direction = 0; self.isLaunched = false; self.move = function () { self.x += self.speed * Math.cos(self.direction); self.y += self.speed * Math.sin(self.direction); self.speed *= 0.95; if (self.isLaunched) { self.distanceTraveled += self.speed; LK.setScore(Math.floor(self.distanceTraveled)); if (self.speed < 0.1) { if (Math.random() < 0.5) { var bouncePower = self.launchPower * (0.1 + Math.random() * 0.8); self.speed = bouncePower; self.direction = -Math.PI / 2; } else { LK.showGameOver(); self.isLaunched = false; } } } }; }); var Lake = Container.expand(function () { var self = Container.call(this); var lakeGraphics = self.createAsset('lake', 'Lake for stone ricochet', .5, .5); self.checkRicochet = function (stone) { if (stone.intersects(this)) { return true; } return false; }; }); var Game = Container.expand(function () { var self = Container.call(this); LK.stageContainer.setBackgroundColor(0x008080); var lake = new Lake(); self.addChildAt(lake, 0); lake.x = 2048 / 2; lake.y = 2732 / 2; var hand = self.addChild(new Hand()); var powerBar = self.addChild(new PowerBar()); var stone = self.addChild(new Stone()); stone.x = hand.x; stone.y = hand.y; var scoreTxt = new Text2('0', { size: 120, fill: "#ffffff" }); LK.gui.topCenter.addChild(scoreTxt); var isGameOver = false; var ricochets = 0; var restartButton = self.addChild(new RestartButton()); restartButton.visible = false; LK.on('tick', function () { if (!stone.isLaunched) {} stone.move(); if (!isGameOver) { scoreTxt.setText(LK.getScore()); } }); var windPowerBar = self.addChild(new WindPowerBar()); windPowerBar.visible = true; stage.on('down', function (obj) { if (!stone.isLaunched && !powerBar.visible && !windPowerBar.visible) { powerBar.show(); } else if (!stone.isLaunched && powerBar.visible && !windPowerBar.visible) { windPowerBar.show(); } else if (!stone.isLaunched && windPowerBar.visible) { stone.launch(hand, powerBar.progress, windPowerBar.progress); windPowerBar.hide(); powerBar.hide(); } }); stage.on('move', function (obj) { var event = obj.event; var pos = event.getLocalPosition(self); hand.move({ x: pos.x }, stone); }); });
===================================================================
--- original.js
+++ change.js
@@ -8,10 +8,10 @@
});
});
var PowerBar = Container.expand(function () {});
var WindPowerBar = PowerBar.expand(function () {
- var self = Container.call(this);
var self = PowerBar.call(this);
+ var self = PowerBar.call(this);
self.createAsset('powerBar', 'Wind power bar display', 0, 0.5);
var windLabel = new Text2('Wind', {
size: 400,
fill: "#ffffff",
A nice lake Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A hand Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A small stone Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A power bar Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A power bar Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
A restart button Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.