User prompt
update Rebirth cost on candy click
User prompt
make it rebirth.buttonText.setText('Rebirth: x' + 2^rebirth.rebirthLevel);
User prompt
you missed one inside if statement of rebirth.on change it to rebirthCost = Math.pow(10, rebirth.rebirthLevel) * 100; also
User prompt
make both rebirthCost = Math.pow(10, rebirth.rebirthLevel) * 100;
User prompt
You have wrong rebirth cost inside If statement
User prompt
change rebirthCost = Math.pow(10, rebirth.rebirthLevel) * 100; inside rebirth on click score condition
User prompt
set text for popupNumber to clickPower * Math.pow(2, rebirth.rebirthLevel); instadof clickPower
User prompt
set text for popUpNumber same as you add for score
User prompt
make it score += clickPower * 2^rebirthLevel
User prompt
Do not increase clickPower on candyClick
User prompt
do not increase Click Power on successfull rebirth, instead of it calculate it on candy Click
User prompt
change rebirth cost formula to (10^rebirthLevel)*100
User prompt
Add a rebirth button same as upgrade button. On click it multiply scare gaining x2. The cost is calculated on formula RebirthCost = Math.Floor(rebirthLvl^10)*100
User prompt
change button graphics width and height instead of scale on click
User prompt
change scale of buttonGraphics instead of self for basicUpgradeButton on click
User prompt
Fix Bug: 'Uncaught TypeError: Graphics is not a constructor' in this line: 'var buttonGraphics = new Graphics();' Line Number: 62
User prompt
make buttonGraphics rounded corners
User prompt
make upgrade.y = 2732-700
User prompt
change buttonGraphics tint to green if it is enough score for cost and to red if it is not
User prompt
change upgradeButton color and bounce it a bit on a click
User prompt
check color of costText on every click of candy
User prompt
Set costText to red if it is not enough score and to green if it is enough score
User prompt
Set buttonText.y to - 100 and costText.y to 0
User prompt
Set buttonText.x and costText.x to -400
User prompt
set buttonText.x to - 450
function formatNumber(num) { if (num >= 1000000) { return (num / 1000000).toFixed(2) + 'M'; } else if (num >= 1000) { return (num / 1000).toFixed(2) + 'K'; } else { return Math.floor(num); } } var RebirthButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.createAsset('rebirthButton', 'Rebirth Button', .5, .5); buttonGraphics.width = 900; buttonGraphics.height = 300; buttonGraphics.tint = 0x00ff00; self.rebirthLevel = 1; self.buttonText = new Text2('Rebirth: x' + self.rebirthLevel, { size: 100, fill: '#ffffff', anchor: { x: 0.5, y: 0.5 }, pivot: { x: 0.5, y: 0.5 } }); self.addChild(self.buttonText); self.buttonText.x = -400; self.buttonText.y = -100; var costText = new Text2('', { size: 100, fill: '#ffffff', anchor: { x: 0.5, y: 0.5 }, pivot: { x: 0.5, y: 0.5 } }); self.addChild(costText); costText.x = -400; costText.y = 0; self.setCost = function (cost, affordable) { costText.setText('Cost: ' + formatNumber(cost)); costText.fill = affordable ? '#00ff00' : '#ff0000'; buttonGraphics.tint = affordable ? 0x00ff00 : 0xff0000; }; self.click = function () { buttonGraphics.width = buttonGraphics.width * 1.1; buttonGraphics.height = buttonGraphics.height * 1.1; LK.setTimeout(function () { buttonGraphics.width = buttonGraphics.width / 1.1; buttonGraphics.height = buttonGraphics.height / 1.1; }, 100); }; }); var PopUpNumber = Container.expand(function () { var self = Container.call(this); self.incomeText = new Text2('Income', { size: 300, fill: '#ffffff', anchor: { x: 0.5, y: 0.5 } }); self.addChild(self.incomeText); self.incomeText.x = 0; self.incomeText.y = 0; self.setText = function (text) { self.incomeText.setText(text); }; self.fly = function (direction) { var speed = 20; var deceleration = 0.98; var flyInterval = LK.setInterval(function () { speed *= deceleration; self.x += Math.cos(direction) * speed; self.y += Math.sin(direction) * speed; self.alpha -= 0.005; 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); candyGraphics.scale.set(3); 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 BasicUpgradeButton = Container.expand(function () { var self = Container.call(this); var buttonGraphics = self.createAsset('upgradeButton', 'Basic Upgrade Button', .5, .5); buttonGraphics.width = 900; buttonGraphics.height = 300; buttonGraphics.tint = 0x00ff00; self.upgradeLevel = 1; self.buttonText = new Text2('Upgrade: +' + self.upgradeLevel, { size: 100, fill: '#ffffff', anchor: { x: 0.5, y: 0.5 }, pivot: { x: 0.5, y: 0.5 } }); self.addChild(self.buttonText); self.buttonText.x = -400; self.buttonText.y = -100; var costText = new Text2('', { size: 100, fill: '#ffffff', anchor: { x: 0.5, y: 0.5 }, pivot: { x: 0.5, y: 0.5 } }); self.addChild(costText); costText.x = -400; costText.y = 0; self.setCost = function (cost, affordable) { costText.setText('Cost: ' + formatNumber(cost)); costText.fill = affordable ? '#00ff00' : '#ff0000'; buttonGraphics.tint = affordable ? 0x00ff00 : 0xff0000; }; self.click = function () { buttonGraphics.width = buttonGraphics.width * 1.1; buttonGraphics.height = buttonGraphics.height * 1.1; LK.setTimeout(function () { buttonGraphics.width = buttonGraphics.width / 1.1; buttonGraphics.height = buttonGraphics.height / 1.1; }, 100); }; }); var Game = Container.expand(function () { var self = Container.call(this); var background = self.createAsset('background3', 'Game Background', .5, .5); background.width *= 2; background.height *= 2; background.x = 2048 / 2; background.y = 2732 / 2; self.addChild(background); var blackLayer = self.createAsset('blackLayer', 'Black Background Layer', .5, .5); blackLayer.width = background.width; blackLayer.height = background.height; blackLayer.x = 2048 / 2; blackLayer.y = 2732 / 2; blackLayer.alpha = 1; self.addChild(blackLayer); var clickIntensity = 0; var score = 0; var clickPower = 1; var candy = self.addChild(new Candy()); var upgrade = self.addChild(new BasicUpgradeButton()); var rebirth = self.addChild(new RebirthButton()); candy.x = 2048 / 2; candy.y = 2732 / 2; upgrade.x = 2048 / 2; upgrade.y = 2732 - 900; rebirth.x = 2048 / 2; rebirth.y = 2732 - 500; 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 * Math.pow(2, rebirth.rebirthLevel); scoreTxt.setText('🍬' + formatNumber(score)); var popUpNumber = self.addChild(new PopUpNumber()); popUpNumber.x = candy.x - candy.width / 2; popUpNumber.y = candy.y - candy.height / 2; var direction = Math.random() * Math.PI * 2; popUpNumber.fly(direction); popUpNumber.setText('🍬' + formatNumber(clickPower * Math.pow(2, rebirth.rebirthLevel))); clickIntensity += (1 - clickIntensity) * 0.05; if (clickIntensity > 1) clickIntensity = 1; blackLayer.alpha = 1 - clickIntensity; var upgradeCost = Math.floor(5 * Math.pow(1.13, upgrade.upgradeLevel)); upgrade.setCost(upgradeCost, score >= upgradeCost); var rebirthCost = Math.pow(10, rebirth.rebirthLevel) * 100; rebirth.setCost(rebirthCost, score >= rebirthCost); }); LK.on('tick', function () { clickIntensity -= 0.002; if (clickIntensity < 0) clickIntensity = 0; blackLayer.alpha = 1 - clickIntensity; }); LK.on('tick', function () { background.rotation += clickIntensity * 0.02; }); upgrade.on('down', function (obj) { var upgradeCost = Math.floor(5 * Math.pow(1.13, upgrade.upgradeLevel)); if (score >= upgradeCost) { score -= upgradeCost; clickPower += 1; upgrade.upgradeLevel++; scoreTxt.setText('🍬' + score); upgrade.buttonText.setText('Upgrade: +' + upgrade.upgradeLevel); upgradeCost = Math.floor(5 * Math.pow(1.13, upgrade.upgradeLevel)); } upgrade.setCost(upgradeCost, score >= upgradeCost); }); rebirth.on('down', function (obj) { var rebirthCost = Math.pow(10, rebirth.rebirthLevel) * 100; if (score >= rebirthCost) { score -= rebirthCost; rebirth.rebirthLevel++; scoreTxt.setText('🍬' + score); rebirth.buttonText.setText('Rebirth: x' + Math.pow(2, rebirth.rebirthLevel)); rebirthCost = Math.pow(10, rebirth.rebirthLevel) * 100; } rebirth.setCost(rebirthCost, score >= rebirthCost); }); var initialCost = 5 * Math.pow(1.13, upgrade.upgradeLevel); upgrade.setCost(initialCost, score >= initialCost); var initialRebirthCost = Math.pow(10, rebirth.rebirthLevel) * 100; rebirth.setCost(initialRebirthCost, score >= initialRebirthCost); });
===================================================================
--- original.js
+++ change.js
@@ -207,8 +207,10 @@
if (clickIntensity > 1) clickIntensity = 1;
blackLayer.alpha = 1 - clickIntensity;
var upgradeCost = Math.floor(5 * Math.pow(1.13, upgrade.upgradeLevel));
upgrade.setCost(upgradeCost, score >= upgradeCost);
+ var rebirthCost = Math.pow(10, rebirth.rebirthLevel) * 100;
+ rebirth.setCost(rebirthCost, score >= rebirthCost);
});
LK.on('tick', function () {
clickIntensity -= 0.002;
if (clickIntensity < 0) clickIntensity = 0;