User prompt
Make a button that you can click to open a menu to buy stuff
User prompt
Make a button that opens a upgrade menu
User prompt
Make the gap bigger
User prompt
Add a gap between each upgrade that says the price and name up the upgrades
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var upgradeGraphics = self.attachAsset(self.name, {' Line Number: 91
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'var upgradeGraphics = self.attachAsset(self.name, {' Line Number: 91
User prompt
Troubleshoot
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'self.attachAsset('upgrade', {' Line Number: 87
User prompt
Make the correct image appear for the upgrades using my assets
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'self.attachAsset('upgrade', {' Line Number: 87
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'self.attachAsset('upgrade', {' Line Number: 87
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'self.attachAsset('upgrade', {' Line Number: 87
User prompt
Make the assets assigned to the correct upgrade
User prompt
Make all the upgrades the same size
User prompt
Assign all the assets the the correct upgrades
User prompt
Add prices of each upgrade below the image and add a name too
User prompt
Make the upgrades image fit there name by creating new assets for them and assigning them
User prompt
Sharpen my game
User prompt
Sharpen my game
User prompt
Sharpen my game
User prompt
Sharpen my game
User prompt
Sharpen my game
User prompt
Please fix the bug: 'Cannot read properties of undefined (reading 'attachAsset')' in or related to this line: 'self.attachAsset('Farm', {' Line Number: 52
User prompt
Make all the upgrades images relate to there names
User prompt
Sharpen my game
/**** * Classes ****/ //<Assets used in the game will automatically appear here> //<Write imports for supported plugins here> // Cookie class to represent the clickable cookie var Cookie = Container.expand(function () { var self = Container.call(this); var cookieGraphics = self.attachAsset('cookie', { anchorX: 0.5, anchorY: 0.5 }); // Event handler for clicking the cookie self.down = function (x, y, obj) { // Increase the cookie count game.cookieCount += game.cookiesPerClick; game.updateScore(); }; }); // Upgrade class to represent purchasable upgrades var Upgrade = Container.expand(function (name, cost, cpsIncrease) { var self = Container.call(this); self.name = name; self.cost = cost; self.cpsIncrease = cpsIncrease; var upgradeGraphics = self.attachAsset('upgrade', { anchorX: 0.5, anchorY: 0.5 }); // Event handler for purchasing the upgrade self.down = function (x, y, obj) { if (game.cookieCount >= self.cost) { game.cookieCount -= self.cost; game.cookiesPerSecond += self.cpsIncrease; self.cost *= 1.2; // Increase the cost by 20% game.updateScore(); // Do not destroy the upgrade after purchase } }; }); var Mine = Upgrade.expand(function () { var self = Upgrade.call(this, 'Mine', 5000, 50); }); var Farm = Upgrade.expand(function () { var self = Upgrade.call(this, 'Farm', 500, 10); }); var Factory = Upgrade.expand(function () { var self = Upgrade.call(this, 'Factory', 2000, 20); }); var Bank = Upgrade.expand(function () { var self = Upgrade.call(this, 'Bank', 10000, 100); }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x0000FF //Init game with blue background }); /**** * Game Code ****/ // Initialize game variables game.cookieCount = 0; game.cookiesPerClick = 1; game.cookiesPerSecond = 0; // Create and position the cookie var cookie = new Cookie(); cookie.x = 2048 / 2; cookie.y = 2732 / 2; game.addChild(cookie); // Create and position upgrades var upgrades = []; var upgrade1 = new Upgrade('Grandma', 100, 1); upgrade1.x = 2048 - 300; upgrade1.y = 500; upgrades.push(upgrade1); game.addChild(upgrade1); var farm = new Farm(); farm.x = 2048 - 300; farm.y = 700; upgrades.push(farm); game.addChild(farm); var factory = new Factory(); factory.x = 2048 - 300; factory.y = 900; upgrades.push(factory); game.addChild(factory); var mine = new Mine(); mine.x = 2048 - 300; mine.y = 1100; upgrades.push(mine); game.addChild(mine); var bank = new Bank(); bank.x = 2048 - 300; bank.y = 1300; upgrades.push(bank); game.addChild(bank); // Create and display the score text var scoreTxt = new Text2('Cookies: 0', { size: 100, fill: 0xFFFFFF }); scoreTxt.anchor.set(0.5, 0); LK.gui.top.addChild(scoreTxt); // Function to update the score display game.updateScore = function () { scoreTxt.setText('Cookies: ' + game.cookieCount); }; // Update function to handle cookies per second game.update = function () { if (LK.ticks % 60 == 0) { // Every second game.cookieCount += game.cookiesPerSecond; game.updateScore(); } };
===================================================================
--- original.js
+++ change.js
@@ -46,8 +46,11 @@
});
var Factory = Upgrade.expand(function () {
var self = Upgrade.call(this, 'Factory', 2000, 20);
});
+var Bank = Upgrade.expand(function () {
+ var self = Upgrade.call(this, 'Bank', 10000, 100);
+});
/****
* Initialize Game
****/
@@ -88,8 +91,13 @@
mine.x = 2048 - 300;
mine.y = 1100;
upgrades.push(mine);
game.addChild(mine);
+var bank = new Bank();
+bank.x = 2048 - 300;
+bank.y = 1300;
+upgrades.push(bank);
+game.addChild(bank);
// Create and display the score text
var scoreTxt = new Text2('Cookies: 0', {
size: 100,
fill: 0xFFFFFF