/**** * Classes ****/ // No plugins needed for this game // Button class: a simple rectangular button with centered text var BlueButton = Container.expand(function () { var self = Container.call(this); // Button dimensions var btnWidth = 600; var btnHeight = 200; // Create button background (rounded rectangle using ellipse for corners) var btnBg = self.attachAsset('buttonBg', { width: btnWidth, height: btnHeight, color: 0x1e90ff, // Dodger blue shape: 'box', anchorX: 0.5, anchorY: 0.5 }); // Button label var btnLabel = new Text2('PRESS ME', { size: 90, fill: 0xFFFFFF }); btnLabel.anchor.set(0.5, 0.5); btnLabel.x = 0; btnLabel.y = 0; self.addChild(btnLabel); // Optional: visual feedback on press self.down = function (x, y, obj) { btnBg.alpha = 0.7; }; self.up = function (x, y, obj) { btnBg.alpha = 1; }; return self; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0xffffff // Start with white background }); /**** * Game Code ****/ // Set initial background color (white) game.setBackgroundColor(0xffffff); // Create the button and center it var blueBtn = new BlueButton(); blueBtn.x = 2048 / 2; blueBtn.y = 2732 / 2; game.addChild(blueBtn); // Prevent button from being placed in the top-left 100x100 area // (It's centered, so this is always satisfied) // Handle button press: turn the whole screen blue blueBtn.up = function (x, y, obj) { // Instantly set background to blue screen color game.setBackgroundColor(0x0078d7); // Classic Windows blue screen color // Optionally, hide the button after press blueBtn.visible = false; // Optionally, show a "sad face" or error text (not required by MVP) // Uncomment below to add a sad face and error text: /* var sadFace = new Text2(':(', { size: 400, fill: "#ffffff" }); sadFace.anchor.set(0.5, 0.5); sadFace.x = 2048 / 2; sadFace.y = 2732 / 2 - 250; game.addChild(sadFace); var errorText = new Text2('Your game ran into a problem and needs to restart.', { size: 70, fill: "#ffffff" }); errorText.anchor.set(0.5, 0.5); errorText.x = 2048 / 2; errorText.y = 2732 / 2 + 100; game.addChild(errorText); */ }; // No update loop or other game logic needed for this MVP // No GUI elements needed // No sounds, music, or other effects per requirements
===================================================================
--- original.js
+++ change.js
@@ -1,6 +1,88 @@
-/****
+/****
+* Classes
+****/
+// No plugins needed for this game
+// Button class: a simple rectangular button with centered text
+var BlueButton = Container.expand(function () {
+ var self = Container.call(this);
+ // Button dimensions
+ var btnWidth = 600;
+ var btnHeight = 200;
+ // Create button background (rounded rectangle using ellipse for corners)
+ var btnBg = self.attachAsset('buttonBg', {
+ width: btnWidth,
+ height: btnHeight,
+ color: 0x1e90ff,
+ // Dodger blue
+ shape: 'box',
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ // Button label
+ var btnLabel = new Text2('PRESS ME', {
+ size: 90,
+ fill: 0xFFFFFF
+ });
+ btnLabel.anchor.set(0.5, 0.5);
+ btnLabel.x = 0;
+ btnLabel.y = 0;
+ self.addChild(btnLabel);
+ // Optional: visual feedback on press
+ self.down = function (x, y, obj) {
+ btnBg.alpha = 0.7;
+ };
+ self.up = function (x, y, obj) {
+ btnBg.alpha = 1;
+ };
+ return self;
+});
+
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000
-});
\ No newline at end of file
+ backgroundColor: 0xffffff // Start with white background
+});
+
+/****
+* Game Code
+****/
+// Set initial background color (white)
+game.setBackgroundColor(0xffffff);
+// Create the button and center it
+var blueBtn = new BlueButton();
+blueBtn.x = 2048 / 2;
+blueBtn.y = 2732 / 2;
+game.addChild(blueBtn);
+// Prevent button from being placed in the top-left 100x100 area
+// (It's centered, so this is always satisfied)
+// Handle button press: turn the whole screen blue
+blueBtn.up = function (x, y, obj) {
+ // Instantly set background to blue screen color
+ game.setBackgroundColor(0x0078d7); // Classic Windows blue screen color
+ // Optionally, hide the button after press
+ blueBtn.visible = false;
+ // Optionally, show a "sad face" or error text (not required by MVP)
+ // Uncomment below to add a sad face and error text:
+ /*
+ var sadFace = new Text2(':(', {
+ size: 400,
+ fill: "#ffffff"
+ });
+ sadFace.anchor.set(0.5, 0.5);
+ sadFace.x = 2048 / 2;
+ sadFace.y = 2732 / 2 - 250;
+ game.addChild(sadFace);
+ var errorText = new Text2('Your game ran into a problem and needs to restart.', {
+ size: 70,
+ fill: "#ffffff"
+ });
+ errorText.anchor.set(0.5, 0.5);
+ errorText.x = 2048 / 2;
+ errorText.y = 2732 / 2 + 100;
+ game.addChild(errorText);
+ */
+};
+// No update loop or other game logic needed for this MVP
+// No GUI elements needed
+// No sounds, music, or other effects per requirements
\ No newline at end of file