Code edit (9 edits merged)
Please save this source code
User prompt
Pad timer text with 0 so the text length is always 3
Code edit (7 edits merged)
Please save this source code
User prompt
Fix Bug: 'Timeout.tick error: timerText.updateTime is not a function. (In 'timerText.updateTime(currentTime)', 'timerText.updateTime' is undefined)' in or related to this line: 'timerText.updateTime(currentTime);' Line Number: 551
User prompt
Update declaration of timerText to make it like balanceText and stockNumber, do not use a class
Code edit (1 edits merged)
Please save this source code
User prompt
For timer, use currentTime=nbTotalStock-graphIndex
User prompt
Fix Bug: 'Timeout.tick error: Can't find variable: startTime' in or related to this line: 'var currentTime = Math.floor((Date.now() - startTime) / 1000);' Line Number: 554
User prompt
Add a timerText at the top left
Code edit (4 edits merged)
Please save this source code
User prompt
Donβt do it, Just tell me how can I make the stocknumber text position fixed ? Independent from Texts lenghts
User prompt
Just tell me how can I make the stocknumber text position fixed ? Independent from Texts lenghts
User prompt
So how can I make the stocknumber text position fixed ? Independent from Texts lenghts
Code edit (5 edits merged)
Please save this source code
User prompt
Fix Bug: 'Script error.' in or related to this line: 'LK.gui.roght.addChild(stockValueText);' Line Number: 400
Code edit (1 edits merged)
Please save this source code
User prompt
Add a timerIcon at the left of the balance icon
Code edit (3 edits merged)
Please save this source code
User prompt
Disable sell button when player has no stocks
Code edit (1 edits merged)
Please save this source code
Code edit (11 edits merged)
Please save this source code
User prompt
make stockValueText follow the current segment y
Code edit (6 edits merged)
Please save this source code
User prompt
move the stock price to the left center
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -14,8 +14,21 @@
anchorX: 0.5,
anchorY: 0.5
});
});
+var TimerText = Container.expand(function () {
+ var self = Container.call(this);
+ var timerText = new Text2('00:00', {
+ size: 100,
+ fill: "#ffffff",
+ anchorX: 0.5
+ });
+ timerText.anchor.set(0.5, 0);
+ self.addChild(timerText);
+ self.updateTime = function (time) {
+ timerText.setText(time);
+ };
+});
var StockIcon = Container.expand(function () {
var self = Container.call(this);
var iconGraphics = self.attachAsset('stockIcon', {
anchorX: 0.5,
@@ -344,15 +357,18 @@
}
};
sellButton.updateButtonState();
var timerIcon = game.addChild(new TimerIcon());
-timerIcon.x = game.width * 0.25; // Position to the left of the balance icon
+var timerText = game.addChild(new TimerText());
+timerText.x = game.width * 0.15;
+timerText.y = game.height * 0.025;
+timerIcon.x = game.width * 0.05; // Position to the left of the balance icon
timerIcon.y = game.height * 0.025;
var balanceIcon = game.addChild(new BalanceIcon());
balanceIcon.x = game.width * 0.5;
balanceIcon.y = game.height * 0.025;
var stockIcon = game.addChild(new StockIcon());
-stockIcon.x = game.width * 0.75;
+stockIcon.x = game.width * 0.95;
stockIcon.y = balanceIcon.y;
var balanceText = new Text2('$' + player.getBalance() + ' ', {
size: 100,
fill: "#ffffff",
@@ -365,9 +381,9 @@
size: 100,
fill: "#ffffff",
anchorX: 0.5
});
-stocksNumber.anchor.set(.5, -0.7);
+stocksNumber.anchor.set(1.5, -0.7);
LK.gui.topRight.addChild(stocksNumber);
// Create a text display for the verticalSlideAmount labeled VSA
var verticalSlideAmount = 0;
var vsaText = new Text2('', {
@@ -517,8 +533,15 @@
stockValueText.alpha = 1;
}, 100);
// Set up a tick event to call drawNextSegment every second
segmentDrawInterval = LK.setInterval(drawNextSegment, 10);
+ // Set up a timer to update the timer text every second
+ var timerUpdateInterval = LK.setInterval(function () {
+ var currentTime = Math.floor((Date.now() - startTime) / 1000);
+ var minutes = Math.floor(currentTime / 60).toString().padStart(2, '0');
+ var seconds = (currentTime % 60).toString().padStart(2, '0');
+ timerText.updateTime(minutes + ':' + seconds);
+ }, 1000);
}
// Main game loop
LK.on('tick', function () {
if (!running) {
A Technical dark background. Nothing just a gradiant of colors from black to dark blue. Theme : stock market. background
A modern clean empty rectangular button without borders. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
without shadow
a basic empty ui popup with a black background. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.