User prompt
Please fix the bug: 'Uncaught TypeError: Cannot read properties of undefined (reading '0')' in or related to this line: 'return;' Line Number: 253
User prompt
Please fix the bug: 'LK.mask is not a function' in or related to this line: 'LK.mask(businessScrollArea, {' Line Number: 591
User prompt
i wanna mask bussiness under earn button
User prompt
go back to before mask branch
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return;' Line Number: 253
User prompt
go to back to adding another business
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return;' Line Number: 253
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return;' Line Number: 253
User prompt
remove last change
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return;' Line Number: 253
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return;' Line Number: 253
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return;' Line Number: 253
User prompt
Please fix the bug: 'Script error.' in or related to this line: 'return;' Line Number: 253
User prompt
mask business if over 8 business
User prompt
add more business type and slideable area for bussiness
User prompt
add transparency to money particle
User prompt
i wanna change money particle image
User prompt
money particle start random position on top of the screen
User prompt
add money particle fall over top when earning money
User prompt
i wanna select how many upgrade i apply when i click x1,x10,x100 add buttons to right of the screen. Vertical order add button for each x
User prompt
add total money text top center
User prompt
remove total money text
User prompt
move center to total money text
User prompt
remove last
User prompt
add coin image next to it
/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { money: 0, businesses: {}, lastTick: 0 }); /**** * Classes ****/ // Business class: represents a single business row var Business = Container.expand(function () { var self = Container.call(this); // Properties (set after creation) self.bizId = null; self.bizData = null; self.index = 0; // UI elements var icon = null; var nameTxt = null; var levelTxt = null; var costTxt = null; var profitTxt = null; var timerBar = null; var upgradeBtn = null; var managerBtn = null; // State self.timer = 0; // ms left for current run self.running = false; // Setup method (called after creation) self.setup = function (bizId, bizData, index) { self.bizId = bizId; self.bizData = bizData; self.index = index; // Icon icon = self.attachAsset(bizData.asset, { anchorX: 0.5, anchorY: 0.5, x: 0, y: 0 }); // Name nameTxt = new Text2(bizData.name, { size: 48, fill: "#222", font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); nameTxt.anchor.set(0, 0.5); nameTxt.x = 140; nameTxt.y = 0; self.addChild(nameTxt); // Level levelTxt = new Text2("Lvl 0", { size: 40, fill: "#444", font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); levelTxt.anchor.set(0, 0.5); levelTxt.x = 140; levelTxt.y = 50; self.addChild(levelTxt); // Cost costTxt = new Text2("Buy: $0", { size: 36, fill: "#666", font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); costTxt.anchor.set(0, 0.5); costTxt.x = 140; costTxt.y = -50; self.addChild(costTxt); // Profit profitTxt = new Text2("+$0", { size: 36, fill: 0x008000, font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma" }); profitTxt.anchor.set(1, 0.5); profitTxt.x = 900; profitTxt.y = 0; self.addChild(profitTxt); // Timer bar background (shows total progress area) var timerBarBg = self.attachAsset('slider_sprite', { anchorX: 0, anchorY: 0.5, x: 140, y: 80, width: 320, height: 24 // match new thinner asset height for best appearance }); timerBarBg.alpha = 0.3; self.addChild(timerBarBg); // Timer bar (progress fill) timerBar = self.attachAsset('slider_sprite', { anchorX: 0, anchorY: 0.5, x: 140, y: 80, width: 0, height: 24 // match new thinner asset height for best appearance }); timerBar.alpha = 0.5; // Upgrade button upgradeBtn = self.attachAsset('upgrade_btn', { anchorX: 0.5, anchorY: 0.5, x: 1100, y: 0 }); upgradeBtn.interactive = true; upgradeBtn.down = function (x, y, obj) { if (self.down) self.down(x, y, upgradeBtn); }; // Removed upgradeTxt label // (Auto/manager button removed) // Event listeners self.down = function (x, y, obj) { // If tap on icon, start business if unlocked if (self.isUnlocked() && !self.isAuto() && self.timer <= 0) { self.startRun(); } // If tap on upgrade button if (self.isUnlocked() && obj === upgradeBtn && upgradeBtn.alpha >= 1) { self.tryUpgrade(); } // (Auto/manager button tap logic removed) // If tap anywhere on the business row and not unlocked, allow buying if (!self.isUnlocked()) { self.tryUpgrade(); } }; // Update UI self.refresh(); }; // Is business unlocked? self.isUnlocked = function () { return businesses[self.bizId].level > 0; }; // Is manager hired? self.isAuto = function () { return businesses[self.bizId].manager; }; // Start a run (manual or auto) self.startRun = function () { if (!self.isUnlocked()) return; if (self.timer > 0) return; self.timer = self.getDuration(); self.running = true; }; // Try to buy/upgrade self.tryUpgrade = function () { var cost = self.getCost(); // Only allow upgrade if enough money and upgradeBtn is enabled if (money >= cost && upgradeBtn.alpha >= 1) { money -= cost; businesses[self.bizId].level += 1; self.refresh(); updateMoneyUI(); saveGame(); } }; // Try to hire manager self.tryHireManager = function () { var mCost = self.getManagerCost(); if (money >= mCost && !self.isAuto()) { money -= mCost; businesses[self.bizId].manager = true; self.refresh(); updateMoneyUI(); saveGame(); } }; // Get current cost to buy/upgrade self.getCost = function () { var lvl = businesses[self.bizId].level; return Math.floor(self.bizData.baseCost * Math.pow(self.bizData.costMult, lvl)); }; // Get current profit self.getProfit = function () { var lvl = businesses[self.bizId].level; if (lvl === 0) return 0; return Math.floor(self.bizData.baseProfit * lvl * Math.pow(1.07, lvl - 1)); }; // Get duration (ms) self.getDuration = function () { return self.bizData.baseTime; }; // Get manager cost self.getManagerCost = function () { return self.bizData.managerCost; }; // Update UI self.refresh = function () { var lvl = businesses[self.bizId].level; var unlocked = lvl > 0; var profit = self.getProfit(); var cost = self.getCost(); var mCost = self.getManagerCost(); levelTxt.setText("Lvl " + lvl); costTxt.setText(unlocked ? "Upgrade: $" + formatNum(cost) : "Buy: $" + formatNum(cost)); profitTxt.setText("+$" + formatNum(profit)); profitTxt.alpha = unlocked ? 1 : 0.3; levelTxt.alpha = unlocked ? 1 : 0.3; icon.alpha = unlocked ? 1 : 0.3; // Timer bar timerBar.width = 320 * (self.timer > 0 ? 1 - self.timer / self.getDuration() : 0); // Upgrade button upgradeBtn.alpha = money >= cost ? 1 : 0.5; // (Auto/manager button UI refresh removed) }; // Update per tick self.update = function () { if (!self.isUnlocked()) { self.refresh(); return; } // Auto-run if manager or level > 1 if ((self.isAuto() || businesses[self.bizId].level > 1) && self.timer <= 0) { self.startRun(); // Ensure running is set so update continues ticking self.running = true; } // Progress timer if (self.timer > 0) { self.timer -= 1000 / 60; if (self.timer <= 0) { self.timer = 0; // Award profit var profit = self.getProfit(); money += profit; updateMoneyUI(); saveGame(); self.refresh(); // If auto, start again next frame } self.refresh(); } }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x87ceeb // Changed to a sky blue color }); /**** * Game Code ****/ // Reference: To change the slider sprite, update the asset below with your own image id and dimensions. // Reference for business row background // Business icons (simple colored boxes for MVP) // --- Game Data --- var businessList = [{ id: 'lemon', name: 'Lemonade Stand', asset: 'biz_lemon', baseCost: 4, costMult: 1.07, baseProfit: 1, baseTime: 1000, managerCost: 100 }, { id: 'newspaper', name: 'Newspaper Delivery', asset: 'biz_newspaper', baseCost: 60, costMult: 1.15, baseProfit: 8, baseTime: 3000, managerCost: 500 }, { id: 'carwash', name: 'Car Wash', asset: 'biz_carwash', baseCost: 720, costMult: 1.14, baseProfit: 64, baseTime: 6000, managerCost: 3000 }, { id: 'pizza', name: 'Pizza Delivery', asset: 'biz_pizza', baseCost: 8640, costMult: 1.13, baseProfit: 576, baseTime: 12000, managerCost: 10000 }, { id: 'movie', name: 'Movie Studio', asset: 'biz_movie', baseCost: 103680, costMult: 1.12, baseProfit: 5184, baseTime: 24000, managerCost: 100000 }, { id: 'bank', name: 'Bank', asset: 'biz_bank', baseCost: 1244160, costMult: 1.11, baseProfit: 46656, baseTime: 48000, managerCost: 500000 }, { id: 'oil', name: 'Oil Company', asset: 'biz_oil', baseCost: 14929920, costMult: 1.10, baseProfit: 419904, baseTime: 96000, managerCost: 1200000 }]; // --- State --- var money = 0; var businesses = {}; var businessObjs = []; var lastTick = 0; // --- UI Elements --- var moneyTxt = null; var tapBtn = null; var tapBtnTxt = null; // --- Utility Functions --- function formatNum(n) { if (n < 1000) return "" + n; var units = ['K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'Dc']; var u = -1; while (n >= 1000 && u < units.length - 1) { n /= 1000; u++; } return n.toFixed(2) + units[u]; } function updateMoneyUI() { moneyTxt.setText("$" + formatNum(money)); } // --- Save/Load --- function saveGame() { storage.money = money; storage.businesses = {}; for (var i = 0; i < businessList.length; ++i) { var id = businessList[i].id; storage.businesses[id + "_level"] = businesses[id].level; storage.businesses[id + "_manager"] = businesses[id].manager; } storage.lastTick = Date.now(); } function loadGame() { money = storage.money || 0; businesses = {}; for (var i = 0; i < businessList.length; ++i) { var id = businessList[i].id; // Start with 1 lemonade stand businesses[id] = { level: id === 'lemon' ? 1 : 0, manager: false }; if (storage.businesses) { if (typeof storage.businesses[id + "_level"] !== "undefined") { businesses[id].level = storage.businesses[id + "_level"]; } if (typeof storage.businesses[id + "_manager"] !== "undefined") { businesses[id].manager = !!storage.businesses[id + "_manager"]; } } } lastTick = storage.lastTick || Date.now(); } // --- Offline Progress --- function applyOfflineEarnings() { var now = Date.now(); var dt = now - lastTick; if (dt < 1000) return; var total = 0; for (var i = 0; i < businessList.length; ++i) { var biz = businessList[i]; var b = businesses[biz.id]; if (b.level > 0 && b.manager) { var cycles = Math.floor(dt / biz.baseTime); var profit = Math.floor(biz.baseProfit * b.level * Math.pow(1.07, b.level - 1)); total += cycles * profit; } } if (total > 0) { money += total; updateMoneyUI(); } } // --- Game Setup --- // Add background image behind all game elements var bgImage = LK.getAsset('bg_main', { anchorX: 0.5, anchorY: 0.5, x: 2048 / 2, y: 2732 / 2, scaleX: 1, scaleY: 1 }); game.addChild(bgImage); function setupUI() { // Removed money display background (money_bg image) // Removed total money text and its container from the top of the GUI updateMoneyUI = function updateMoneyUI() { // No UI update needed since money text is removed }; // Tap button (big, bottom center) tapBtn = LK.getAsset('tap_btn', { anchorX: 0.5, anchorY: 1, // bottom anchor x: 2048 / 2, y: 2732 - 320 // 320px above bottom (moved up) }); tapBtn.interactive = true; game.addChild(tapBtn); // Removed tapBtnTxt label tapBtn.down = function (x, y, obj) { if (game.down) game.down(x, y, tapBtn); }; // Business rows var startY = 500; var gapY = 260; // Further increased gap for even more space between businesses for (var i = 0; i < businessList.length; ++i) { var biz = businessList[i]; // Add background image for business row var bizRowBg = LK.getAsset('biz_row_bg', { anchorX: 0, anchorY: 0.5, x: 80, // moved a little bit further left from 100 to 80 y: startY + i * gapY, scaleX: 1, scaleY: 1 }); bizRowBg.alpha = 0.5; // Set transparency for business row background game.addChild(bizRowBg); // Create business row on top of background var bizObj = new Business(); bizObj.setup(biz.id, biz, i); bizObj.x = 200; bizObj.y = startY + i * gapY; game.addChild(bizObj); businessObjs.push(bizObj); } } // --- Tap Handler --- game.down = function (x, y, obj) { // Tap on tapBtn if (obj === tapBtn || obj === tapBtnTxt) { var tapVal = 1 + Math.floor(businesses['lemon'].level / 10); money += tapVal; updateMoneyUI(); saveGame(); // Animate tapBtn tween(tapBtn, { scaleX: 0.9, scaleY: 0.9 }, { duration: 80, easing: tween.easeOut, onFinish: function onFinish() { tween(tapBtn, { scaleX: 1, scaleY: 1 }, { duration: 80, easing: tween.easeIn }); } }); } }; // --- Game Update --- game.update = function () { // Update all businesses for (var i = 0; i < businessObjs.length; ++i) { businessObjs[i].update(); } }; // --- Init --- loadGame(); applyOfflineEarnings(); setupUI(); updateMoneyUI(); // --- Save every 5 seconds --- LK.setInterval(function () { saveGame(); }, 5000);
===================================================================
--- original.js
+++ change.js
@@ -407,30 +407,11 @@
});
game.addChild(bgImage);
function setupUI() {
// Removed money display background (money_bg image)
- moneyTxt = new Text2("$0", {
- size: 90,
- fill: "#222",
- font: "'GillSans-Bold', Impact, 'Arial Black', Tahoma"
- });
- moneyTxt.anchor.set(0.5, 0);
- // We'll use a container to keep the money text centered
- var moneyContainer = new Container();
- moneyContainer.addChild(moneyTxt);
- moneyTxt.x = 0;
- moneyTxt.y = 0;
- moneyContainer.x = 2048 / 2;
- moneyContainer.y = 0;
- LK.gui.top.addChild(moneyContainer);
- var _oldUpdateMoneyUI = updateMoneyUI;
+ // Removed total money text and its container from the top of the GUI
updateMoneyUI = function updateMoneyUI() {
- if (moneyTxt) moneyTxt.setText("$" + formatNum(money));
- // Optionally, re-center the container if the text width changes a lot
- if (moneyContainer) {
- moneyTxt.x = 0;
- moneyContainer.x = 2048 / 2;
- }
+ // No UI update needed since money text is removed
};
// Tap button (big, bottom center)
tapBtn = LK.getAsset('tap_btn', {
anchorX: 0.5,
button when clicked earn gold. In-Game asset. 2d. High contrast. No shadows
button upgrade level of business. In-Game asset. 2d. High contrast. No shadows
lemonade stand. In-Game asset. 2d. High contrast. No shadows
newspaper delivery. In-Game asset. 2d. High contrast. No shadows
carwash bussiness. In-Game asset. 2d. High contrast. No shadows
pizza store. In-Game asset. 2d. High contrast. No shadows
movie theater. In-Game asset. 2d. High contrast. No shadows
bank. In-Game asset. 2d. High contrast. No shadows
oil company. In-Game asset. 2d. High contrast. No shadows
background for game clean minimalist. In-Game asset. 2d. High contrast. No shadows
dollar paper. In-Game asset. 2d. High contrast. No shadows