Code edit (18 edits merged)
Please save this source code
User prompt
Fix Bug: 'Uncaught ReferenceError: BalanceIcon is not defined' in or related to this line: 'var balanceIcon = game.addChild(new BalanceIcon());' Line Number: 307
User prompt
Add a new stockIcon asset similar to balanceIcon, place it at the right of balanceIcon
Code edit (1 edits merged)
Please save this source code
User prompt
add a new icon for balance
Code edit (1 edits merged)
Please save this source code
Code edit (7 edits merged)
Please save this source code
User prompt
'reuse' the axis labels and ensure that values are always visible without creating too many Text label instances, you can implement a recycling mechanism for the labels.
User prompt
make axis labels values dynamic so that visible values are always centered on stockValuesHistory[graphIndex + 1]
Code edit (2 edits merged)
Please save this source code
User prompt
call labels updatePosition with the y position of horizontal axis
Code edit (1 edits merged)
Please save this source code
User prompt
instiate axis labels (but not as children of vertical axis)
Code edit (4 edits merged)
Please save this source code
User prompt
detach the labels from the vertical axis : the should not be children of vertivalAxis
Code edit (1 edits merged)
Please save this source code
User prompt
Rotate labels by -90°
User prompt
AxisLabels should not be rotated like the axis
Code edit (1 edits merged)
Please save this source code
User prompt
add to the vertical axis dynamic values with a step of 50
Code edit (1 edits merged)
Please save this source code
User prompt
add dynamic values (step of 50) to the vertical axis
Code edit (3 edits merged)
Please save this source code
User prompt
fix text markers position because gui coordinates are not like other assets coordinates
User prompt
fix text markers position because LK.gui don't work with coordinates like game.height * 0.5
===================================================================
--- original.js
+++ change.js
@@ -1,7 +1,20 @@
/****
* Classes
****/
+var AxisLabel = Container.expand(function (value) {
+ var self = Container.call(this);
+ self.value = value;
+ var label = new Text2('$' + value, {
+ size: 30,
+ fill: "#ffffff"
+ });
+ label.anchor.set(0.5, 0.5);
+ self.addChild(label);
+ self.updatePosition = function (axisY) {
+ self.y = axisY - value * dollarToYPixelRatio;
+ };
+});
var GraphSegment = Container.expand(function () {
var self = Container.call(this);
self.index1 = null;
self.stockValue1 = 0;
@@ -61,8 +74,16 @@
self.drawAxis = function () {
var axisGraphics = self.addChild(LK.getAsset('axis', {
height: 4 // Thin line for the axis
}));
+ if (self.isVertical) {
+ for (var i = 50; i <= 1000; i += 50) {
+ var label = new AxisLabel(i);
+ label.x = -30; // Position the label to the left of the axis
+ self.addChild(label);
+ label.updatePosition(self.y);
+ }
+ }
};
});
// ValueIndicator class to represent the current value of the stock on the graph
// Player class to represent the player's portfolio
@@ -421,8 +442,16 @@
graphSegments.forEach(function (segment) {
segment.updateSlide();
});
horizontalAxis.updateSlide(); // Slide the horizontal axis vertically
+ // Update the position of the axis labels
+ if (verticalAxis.children) {
+ verticalAxis.children.forEach(function (child) {
+ if (child instanceof AxisLabel) {
+ child.updatePosition(verticalAxis.y);
+ }
+ });
+ }
// Update the vertical slide amount text periodically
vsaText.setText(graphIndex + ' VSA: ' + verticalSlideAmount.toFixed(0) + " " + moveSegmentsVertically);
// Check for game over conditions (e.g., player runs out of money)
if (player.getBalance() <= 0) {
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.