User prompt
Mirror the image of the light switch asset in a horizontal direction when the player clicks on it.
User prompt
Mirror the image of the light switch asset in a horizontal direction when the player clicks on it.
User prompt
Mirror the light switch asset vertically when clicked
User prompt
Mirror the light switch asset vertically when clicked
User prompt
Mirror the light switch asset vertically when clicked
User prompt
Mirror the image of the light switch asset in a horizontal direction when the player clicks on it.
User prompt
Mirror the image of the lightswitch asset vertically when the player clicks on it.
User prompt
Mirror the asset image of the light switch vertically when clicked by the player.
User prompt
Mirror the asset image of the light switch vertically when clicked by the player.
User prompt
Mirror the image of the light switch asset horizontally when clicked by the player.
User prompt
Please fix the bug: 'Error: The supplied DisplayObject must be a child of the caller' in or related to this line: 'self.setChildIndex(switchOffGraphics, self.children.length - 1); // Place lightswitch-off in front of lightswitch' Line Number: 135
User prompt
Place lightswitch-off to Lightswitch
User prompt
Place lightswitch-off in front of the lightswitch.
User prompt
Place lightswitch-off. in front of the lightswitch.
User prompt
Place lightswitch-off. Towards Lightswitch-Off in order
User prompt
Add lightswitch-off to the track. Align the bottom of the lightswitch-off with the top of the lightswitch.
User prompt
If the ceiling light has fallen, then already by clicking on the lamp switch, nothing will happen.
User prompt
If the ceiling light has fallen, then game over
User prompt
The ceiling light is placed in front of the wallpaper in order even if the player has already clicked 10 times
User prompt
Slow down the ceiling light drop rate by half.
User prompt
Slow down the ceiling light drop speed by half
User prompt
Slow down the ceiling light drop speed by half
User prompt
Slow down the ceiling light drop speed by half
User prompt
Slow down the ceiling light drop speed by half
User prompt
If a player clicks on the ceiling light 10 times in a row, the lamp will drop to the ground behind the table asset. At the same time, darkOverlay will turn on. The ceiling light is hidden behind the boxlid, cat, catpaw, woodenbox, toggleswitch and table.
/****
* Classes
****/
// Define a class for the Box Lid
var BoxLid = Container.expand(function () {
var self = Container.call(this);
var boxLidGraphics = self.attachAsset('boxLid', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2; // Center the box lid horizontally
self.y = 2732 / 2 + 270; // Position the box lid to fit the bottom to the top of the box
});
// Assets will be automatically created and loaded by the LK engine based on their usage in the code.
// Define a class for the Cat
var Cat = Container.expand(function () {
var self = Container.call(this);
var catGraphics = self.attachAsset('cat', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2;
self.y = 2732 / 2 + 190;
});
// Define a class for the Cat Paw
var CatPaw = Container.expand(function () {
var self = Container.call(this);
var pawGraphics = self.attachAsset('catPaw', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 + 110 - 50 + 10;
self.y = 2732 / 2 + 550; // Move the cat arm up by 10 units
});
// Define a class for the Ceiling Light
var CeilingLight = Container.expand(function () {
var self = Container.call(this);
var lightGraphics = self.attachAsset('ceilingLight', {
anchorX: 0.5,
anchorY: 0.0
});
self.x = 2048 / 2; // Center the ceiling light horizontally
self.y = 2732 / 2 - 1400; // Move the ceiling light up by 300 units
// Initialize swaying properties
self.swaySpeed = 0.01;
self.swayDirection = 1;
self.swaying = false;
self.swayCount = 0;
// Method to start swaying
self.startSwaying = function () {
if (!self.swaying) {
self.swaying = true;
self.swayCount = 0;
self.swaySpeed = 0.01; // Reset sway speed to default
}
};
// Method to update swaying
self.updateSwaying = function () {
if (self.swaying) {
self.rotation += self.swaySpeed * self.swayDirection;
if (self.rotation > 0.349 || self.rotation < -0.349) {
// 20 degrees in radians
self.swayDirection *= -1;
}
self.swayCount++;
if (self.swayCount > 120) {
// 2 seconds at 60 FPS
self.swaySpeed *= 0.99; // Gradually slow down
if (Math.abs(self.rotation) < 0.01) {
self.rotation = 0; // Reset to original position
self.swaying = false; // Stop swaying
}
}
}
};
// Event handler for when the ceiling light is touched
self.down = function (x, y, obj) {
self.startSwaying();
self.clickCount = (self.clickCount || 0) + 1; // Increment click count
if (self.clickCount >= 10) {
self.y = 2732 / 2 + 2200; // Drop the ceiling light behind the table
darkOverlay.toggle(); // Turn on the dark overlay
self.visible = false; // Hide the ceiling light
self.clickCount = 0; // Reset click count
}
self.swaySpeed *= 1.5; // Increase swaying speed
self.swayCount = 0; // Reset sway count
};
});
// Define a class for the DarkOverlay
var DarkOverlay = Container.expand(function () {
var self = Container.call(this);
var overlayGraphics = LK.getAsset('darkOverlay', {
anchorX: 0.0,
anchorY: 0.0,
width: 2048,
height: 2732,
alpha: 0.95
});
self.addChild(overlayGraphics);
self.visible = false; // Initially hidden
// Method to toggle visibility
self.toggle = function () {
self.visible = !self.visible;
};
});
// Define a class for the LightSwitch
var LightSwitch = Container.expand(function () {
var self = Container.call(this);
var switchGraphics = self.attachAsset('lightswitch', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 + 800;
self.y = 2732 / 2 - 500; // Move the light switch up by 500 units
self.isTouched = false;
// Event handler for when the switch is touched
self.down = function (x, y, obj) {
self.isTouched = true;
};
});
// Define a class for the Table
var Table = Container.expand(function () {
var self = Container.call(this);
var tableGraphics = self.attachAsset('table', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2; // Center the table horizontally
self.y = 2732 / 2 + 2200; // Move the table down by 2000 units
});
// Define a class for the Toggle Switch
var ToggleSwitch = Container.expand(function () {
var self = Container.call(this);
var switchGraphics = self.attachAsset('toggleSwitch', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2;
self.y = 2732 / 2 + 700; // Move the toggle switch up by 20 units
self.isTouched = false;
// Event handler for when the switch is touched
self.down = function (x, y, obj) {
self.isTouched = true;
};
});
// Define a class for the Wallpaper
var Wallpaper = Container.expand(function () {
var self = Container.call(this);
var wallpaperGraphics = self.attachAsset('wallpaper', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2 - 10; // Move the wallpaper left by 10 units
self.y = 2732 / 2 - 300; // Move the wallpaper up by 300 units
});
// Define a class for the Wooden Box
var WoodenBox = Container.expand(function () {
var self = Container.call(this);
var boxGraphics = self.attachAsset('woodenBox', {
anchorX: 0.5,
anchorY: 0.5
});
self.x = 2048 / 2; // Center the wooden box horizontally
self.y = 2732 / 2 + 720; // Move the wooden box down by 220 units
});
/****
* Initialize Game
****/
var game = new LK.Game({
backgroundColor: 0x000000 // Init game with black background
});
/****
* Game Code
****/
// Add the wallpaper to the game
var wallpaper = game.addChild(new Wallpaper());
// Add the ceiling light to the game
ceilingLight = game.addChild(new CeilingLight());
// Add the box lid to the game
var boxLid = game.addChild(new BoxLid());
// Initialize game elements
var cat = game.addChild(new Cat());
// Add the table to the game
var table = game.addChild(new Table());
// Add the wooden box to the game
var woodenBox = game.addChild(new WoodenBox());
var toggleSwitch = game.addChild(new ToggleSwitch());
var lightSwitch = game.addChild(new LightSwitch());
var catPaw = game.addChild(new CatPaw());
// Add the dark overlay to the game
darkOverlay = game.addChild(new DarkOverlay());
// Game update loop
game.update = function () {
// Check if the light switch is touched
if (lightSwitch.isTouched) {
darkOverlay.toggle(); // Toggle the dark overlay
lightSwitch.isTouched = false; // Reset the switch state
}
ceilingLight.updateSwaying(); // Update swaying effect for ceiling light
};
// Handle touch events on the game
game.down = function (x, y, obj) {
// Convert global coordinates to local game coordinates
var localPos = game.toLocal(obj.global);
// Check if the touch is on the light switch
if (lightSwitch.intersects({
x: localPos.x,
y: localPos.y,
width: 1,
height: 1
})) {
lightSwitch.down(x, y, obj);
LK.effects.flashScreen(0xff0000, 1000); // Flash screen red
LK.showGameOver(); // End the game
}
};
Tricolor cat face view. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
simple coffee table front view.
matte white rockerSwitch front view.
fehér fényű mennyezeti lámpa.
yellow stickyNote with "Let the cat sleep! Xoxo!" text and a red-stain.
thin, black, up and down arrow.