User prompt
Make atext inside upgrade button fit into background
User prompt
Change the text on UpgradeButton to "Upgrade"
User prompt
Fix Bug: 'Uncaught TypeError: self.createButton is not a function' in this line: 'var upgradeButton = self.createButton('upgrade', 'Upgrade Button', .5, .5);' Line Number: 46
User prompt
Make an upgrade a button, not asset
User prompt
Fix Bug: 'TypeError: LK.playSound is not a function' in this line: 'LK.playSound('click');' Line Number: 38
User prompt
add sound on button click
User prompt
save my changes
User prompt
Fix Bug: 'TypeError: popUpNumber.setText is not a function' in this line: 'popUpNumber.setText('🍬' + clickPower);' Line Number: 72
User prompt
remove setText function from PopUpNumber
User prompt
delete numBerGraphics from PopUp number
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'if (self.alpha <= 0 || speed < 0.1) {' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'self.incomeText.alpha = self.alpha;' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'if (self.incomeText) {' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'if (self.incomeText) {' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'if (('incomeText' in self)) {' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'if (self.incomeText) {' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'if (self.hasOwnProperty('incomeText')) {' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'if (self.incomeText) {' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'self.incomeText.alpha = 1;' Line Number: 18
User prompt
Fix Bug: 'Timeout.tick error: incomeText is not defined' in this line: 'incomeText.alpha = 1;' Line Number: 18
User prompt
Fix Bug: 'TypeError: Cannot set properties of undefined (setting 'text')' in this line: 'self.incomeText.text = '🍬' + text;' Line Number: 26
User prompt
Income text have to be a text, not asset
User prompt
income text doesn't show, can you fix it?
User prompt
Fix Bug: 'TypeError: Cannot read properties of undefined (reading 'setText')' in this line: 'popUpNumber.incomeText.setText('🍬' + self.scoreTxt.text);' Line Number: 70
User prompt
Make scoreTxt visible inside PopUpButton
var PopUpNumber = Container.expand(function () { var self = Container.call(this); self.incomeText = new Text2('Income', { size: 50, fill: '#ffffff' }); self.addChild(self.incomeText); self.setText = function (text) { self.incomeText.setText(text); }; self.fly = function (direction) { var speed = 10; var deceleration = 0.95; var flyInterval = LK.setInterval(function () { speed *= deceleration; self.x += Math.cos(direction) * speed; self.y += Math.sin(direction) * speed; self.alpha -= 0.01; if (self.incomeText) { self.incomeText.alpha = self.alpha; } if (self.alpha <= 0 || speed < 0.1) { LK.clearInterval(flyInterval); if (self.incomeText) { self.incomeText.destroy(); } self.destroy(); } }, 16); }; }); var Candy = Container.expand(function () { var self = Container.call(this); var candyGraphics = self.createAsset('candy', 'Candy Graphics', .5, .5); self.click = function () { self.scale.x = 1.1; self.scale.y = 1.1; LK.setTimeout(function () { self.scale.x = 1; self.scale.y = 1; }, 100); }; }); var Upgrade = Container.expand(function () { var self = Container.call(this); var upgradeButton = self.createAsset('upgrade', 'Upgrade Button', .5, .5); var upgradeText = new Text2('Upgrade', { size: 30, fill: '#ffffff' }); self.addChild(upgradeText); upgradeText.x = upgradeButton.width / 2; upgradeText.y = upgradeButton.height / 2; self.click = function () {}; }); var Game = Container.expand(function () { var self = Container.call(this); var score = 0; var clickPower = 1; var candy = self.addChild(new Candy()); var upgrade = self.addChild(new Upgrade()); candy.x = 2048 / 2; candy.y = 2732 / 2; upgrade.x = 2048 / 2; upgrade.y = 2732 / 2 + 200; var scoreTxt = new Text2('🍬0', { size: 150, fill: "#ffffff" }); scoreTxt.anchor.set(.5, 0); LK.gui.topCenter.addChild(scoreTxt); self.scoreTxt = scoreTxt; candy.on('down', function (obj) { candy.click(); score += clickPower; scoreTxt.setText('🍬' + score); var popUpNumber = self.addChild(new PopUpNumber()); popUpNumber.x = candy.x; popUpNumber.y = candy.y; var direction = Math.random() * Math.PI * 2; popUpNumber.fly(direction); popUpNumber.setText('🍬' + clickPower); }); upgrade.on('down', function (obj) { if (score >= 10) { score -= 10; clickPower += 1; scoreTxt.setText('🍬' + score); } }); });
===================================================================
--- original.js
+++ change.js
@@ -44,12 +44,14 @@
var Upgrade = Container.expand(function () {
var self = Container.call(this);
var upgradeButton = self.createAsset('upgrade', 'Upgrade Button', .5, .5);
var upgradeText = new Text2('Upgrade', {
- size: 50,
+ size: 30,
fill: '#ffffff'
});
self.addChild(upgradeText);
+ upgradeText.x = upgradeButton.width / 2;
+ upgradeText.y = upgradeButton.height / 2;
self.click = function () {};
});
var Game = Container.expand(function () {
var self = Container.call(this);