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);
var numberGraphics = self.createAsset('number', 'Number Graphics', .5, .5);
var incomeText = self.createAsset('incomeText', 'Income Text', .5, .5);
incomeText.text = 'Income';
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;
numberGraphics.alpha -= 0.01;
incomeText.alpha -= 0.01;
if (self.alpha <= 0 || speed < 0.1) {
LK.clearInterval(flyInterval);
self.destroy();
}
}, 16);
};
self.setText = function (text) {
numberGraphics.text = '🍬' + text;
};
});
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 upgradeGraphics = self.createAsset('upgrade', 'Upgrade Graphics', .5, .5);
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);
popUpNumber.incomeText.setText('🍬' + self.scoreTxt.text);
});
upgrade.on('down', function (obj) {
if (score >= 10) {
score -= 10;
clickPower += 1;
scoreTxt.setText('🍬' + score);
}
});
});