/**** * Classes ****/ // Coloring class var Coloring = Container.expand(function () { var self = Container.call(this); var coloringGraphics = self.attachAsset('coloring', { anchorX: 0.5, anchorY: 0.5, depth: 0.5 // Add depth for 3D effect }); self.color = function (color) { coloringGraphics.tint = color; }; }); //<Assets used in the game will automatically appear here> // Doll class var Doll = Container.expand(function () { var self = Container.call(this); var dollGraphics = self.attachAsset('doll', { anchorX: 0.5, anchorY: 0.5, depth: 0.5 // Add depth for 3D effect }); self.dress = function (dressAsset) { var dress = self.attachAsset(dressAsset, { anchorX: 0.5, anchorY: 0.5 }); dress.y = -dollGraphics.height / 2 + dress.height / 2; }; self.containsPoint = function (point) { var bounds = self.getBounds(); return bounds.contains(point.x, point.y); }; }); // House class var House = Container.expand(function () { var self = Container.call(this); var houseGraphics = self.attachAsset('house', { anchorX: 0.5, anchorY: 0.5, depth: 0.5 // Add depth for 3D effect }); self.clean = function () { // Cleaning logic console.log("House cleaned"); }; }); // Puzzle class var Puzzle = Container.expand(function () { var self = Container.call(this); var puzzleGraphics = self.attachAsset('puzzle', { anchorX: 0.5, anchorY: 0.5, depth: 0.5 // Add depth for 3D effect }); self.solve = function () { // Puzzle solving logic console.log("Puzzle solved"); }; }); /**** * Initialize Game ****/ var game = new LK.Game({ backgroundColor: 0x000000, //Init game with black background renderer: '3d' // Enable 3D rendering }); /**** * Game Code ****/ // Initialize dolls var dolls = []; for (var i = 0; i < 3; i++) { var doll = new Doll(); doll.x = 200 + i * 300; doll.y = 500; dolls.push(doll); game.addChild(doll); } // Initialize house var house = new House(); house.x = 1024; house.y = 1366; game.addChild(house); // Initialize puzzle var puzzle = new Puzzle(); puzzle.x = 1024; puzzle.y = 2000; game.addChild(puzzle); // Initialize coloring var coloring = new Coloring(); coloring.x = 1024; coloring.y = 2500; game.addChild(coloring); // Event listeners for dressing dolls game.down = function (x, y, obj) { var game_position = game.toLocal(obj.global); dolls.forEach(function (doll) { if (doll.containsPoint(game_position)) { doll.dress('dressAsset'); } }); }; // Event listeners for cleaning house house.down = function (x, y, obj) { house.clean(); }; // Event listeners for solving puzzle puzzle.down = function (x, y, obj) { puzzle.solve(); }; // Event listeners for coloring coloring.down = function (x, y, obj) { coloring.color(0xff0000); // Example color }; // Update function game.update = function () { // Game update logic };
===================================================================
--- original.js
+++ change.js
@@ -5,9 +5,10 @@
var Coloring = Container.expand(function () {
var self = Container.call(this);
var coloringGraphics = self.attachAsset('coloring', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ depth: 0.5 // Add depth for 3D effect
});
self.color = function (color) {
coloringGraphics.tint = color;
};
@@ -17,9 +18,10 @@
var Doll = Container.expand(function () {
var self = Container.call(this);
var dollGraphics = self.attachAsset('doll', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ depth: 0.5 // Add depth for 3D effect
});
self.dress = function (dressAsset) {
var dress = self.attachAsset(dressAsset, {
anchorX: 0.5,
@@ -36,9 +38,10 @@
var House = Container.expand(function () {
var self = Container.call(this);
var houseGraphics = self.attachAsset('house', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ depth: 0.5 // Add depth for 3D effect
});
self.clean = function () {
// Cleaning logic
console.log("House cleaned");
@@ -48,9 +51,10 @@
var Puzzle = Container.expand(function () {
var self = Container.call(this);
var puzzleGraphics = self.attachAsset('puzzle', {
anchorX: 0.5,
- anchorY: 0.5
+ anchorY: 0.5,
+ depth: 0.5 // Add depth for 3D effect
});
self.solve = function () {
// Puzzle solving logic
console.log("Puzzle solved");
@@ -60,9 +64,11 @@
/****
* Initialize Game
****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000,
+ //Init game with black background
+ renderer: '3d' // Enable 3D rendering
});
/****
* Game Code