/**** * Plugins ****/ var tween = LK.import("@upit/tween.v1"); var storage = LK.import("@upit/storage.v1", { totalMoney: 0 }); /**** * Classes ****/ var MoneyBill = Container.expand(function () { var self = Container.call(this); var billGraphics = self.attachAsset('moneySquare', { anchorX: 0.5, anchorY: 0.5, alpha: 0.9 }); var moneyText = new Text2('$100', { size: 80, fill: 0xFFFFFF }); moneyText.anchor.set(0.5, 0.5); self.addChild(moneyText); self.down = function (x, y, obj) { // Play money sound LK.getSound('cashSound').play(); // Stop any existing animations tween.stop(self, { scaleX: true, scaleY: true }); // Grow animation tween(self, { scaleX: 1.2, scaleY: 1.2 }, { duration: 100, easing: tween.easeOut, onFinish: function onFinish() { // Shrink back animation tween(self, { scaleX: 1, scaleY: 1 }, { duration: 100, easing: tween.easeIn }); } }); // Increment money counter totalMoney += 100; storage.totalMoney = totalMoney; // Update money display updateMoneyDisplay(); }; return self; }); var MoneyCounter = Container.expand(function () { var self = Container.call(this); var counterText = new Text2('$0', { size: 100, fill: 0xFFFFFF }); counterText.anchor.set(0.5, 0); self.addChild(counterText); self.updateCounter = function (amount) { counterText.setText('$' + amount.toLocaleString()); }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x008000 }); /**** * Game Code ****/ // Initialize variables var totalMoney = storage.totalMoney || 0; var moneyBill, moneyCounter; // Setup game environment game.setBackgroundColor(0x006400); // Dark green background // Create money bill moneyBill = new MoneyBill(); moneyBill.x = 2048 / 2; // Center horizontally moneyBill.y = 2732 / 2; // Center vertically game.addChild(moneyBill); // Create money counter moneyCounter = new MoneyCounter(); LK.gui.top.addChild(moneyCounter); // Update money display function function updateMoneyDisplay() { moneyCounter.updateCounter(totalMoney); } // Initial update of the money display updateMoneyDisplay(); // Start background music LK.playMusic('moneyMusic', { fade: { start: 0, end: 0.8, duration: 1000 } }); // Game update function game.update = function () { // This game doesn't need per-frame updates // Most interactions are handled by the event listeners }; // Handle game touches/clicks game.down = function (x, y, obj) { // This is handled in the MoneyBill class };
/****
* Plugins
****/
var tween = LK.import("@upit/tween.v1");
var storage = LK.import("@upit/storage.v1", {
totalMoney: 0
});
/****
* Classes
****/
var MoneyBill = Container.expand(function () {
var self = Container.call(this);
var billGraphics = self.attachAsset('moneySquare', {
anchorX: 0.5,
anchorY: 0.5,
alpha: 0.9
});
var moneyText = new Text2('$100', {
size: 80,
fill: 0xFFFFFF
});
moneyText.anchor.set(0.5, 0.5);
self.addChild(moneyText);
self.down = function (x, y, obj) {
// Play money sound
LK.getSound('cashSound').play();
// Stop any existing animations
tween.stop(self, {
scaleX: true,
scaleY: true
});
// Grow animation
tween(self, {
scaleX: 1.2,
scaleY: 1.2
}, {
duration: 100,
easing: tween.easeOut,
onFinish: function onFinish() {
// Shrink back animation
tween(self, {
scaleX: 1,
scaleY: 1
}, {
duration: 100,
easing: tween.easeIn
});
}
});
// Increment money counter
totalMoney += 100;
storage.totalMoney = totalMoney;
// Update money display
updateMoneyDisplay();
};
return self;
});
var MoneyCounter = Container.expand(function () {
var self = Container.call(this);
var counterText = new Text2('$0', {
size: 100,
fill: 0xFFFFFF
});
counterText.anchor.set(0.5, 0);
self.addChild(counterText);
self.updateCounter = function (amount) {
counterText.setText('$' + amount.toLocaleString());
};
return self;
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x008000
});
/****
* Game Code
****/
// Initialize variables
var totalMoney = storage.totalMoney || 0;
var moneyBill, moneyCounter;
// Setup game environment
game.setBackgroundColor(0x006400); // Dark green background
// Create money bill
moneyBill = new MoneyBill();
moneyBill.x = 2048 / 2; // Center horizontally
moneyBill.y = 2732 / 2; // Center vertically
game.addChild(moneyBill);
// Create money counter
moneyCounter = new MoneyCounter();
LK.gui.top.addChild(moneyCounter);
// Update money display function
function updateMoneyDisplay() {
moneyCounter.updateCounter(totalMoney);
}
// Initial update of the money display
updateMoneyDisplay();
// Start background music
LK.playMusic('moneyMusic', {
fade: {
start: 0,
end: 0.8,
duration: 1000
}
});
// Game update function
game.update = function () {
// This game doesn't need per-frame updates
// Most interactions are handled by the event listeners
};
// Handle game touches/clicks
game.down = function (x, y, obj) {
// This is handled in the MoneyBill class
};