===================================================================
--- original.js
+++ change.js
@@ -1,77 +1,81 @@
-/****
+/****
* Classes
-****/
+****/
// Coloring class
var Coloring = Container.expand(function () {
- var self = Container.call(this);
- var coloringGraphics = self.attachAsset('coloring', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- self.color = function (color) {
- coloringGraphics.tint = color;
- };
+ var self = Container.call(this);
+ var coloringGraphics = self.attachAsset('coloring', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ 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
- });
- self.dress = function (dressAsset) {
- var dress = self.attachAsset(dressAsset, {
- anchorX: 0.5,
- anchorY: 0.5
- });
- dress.y = -dollGraphics.height / 2 + dress.height / 2;
- };
+ var self = Container.call(this);
+ var dollGraphics = self.attachAsset('doll', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ 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
- });
- self.clean = function () {
- // Cleaning logic
- console.log("House cleaned");
- };
+ var self = Container.call(this);
+ var houseGraphics = self.attachAsset('house', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ 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
- });
- self.solve = function () {
- // Puzzle solving logic
- console.log("Puzzle solved");
- };
+ var self = Container.call(this);
+ var puzzleGraphics = self.attachAsset('puzzle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ self.solve = function () {
+ // Puzzle solving logic
+ console.log("Puzzle solved");
+ };
});
-/****
+/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
- backgroundColor: 0x000000 //Init game with black background
+ backgroundColor: 0x000000 //Init game with black background
});
-/****
+/****
* 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);
+ 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;
@@ -88,27 +92,27 @@
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');
- }
- });
+ 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();
+ house.clean();
};
// Event listeners for solving puzzle
puzzle.down = function (x, y, obj) {
- puzzle.solve();
+ puzzle.solve();
};
// Event listeners for coloring
coloring.down = function (x, y, obj) {
- coloring.color(0xff0000); // Example color
+ coloring.color(0xff0000); // Example color
};
// Update function
game.update = function () {
- // Game update logic
+ // Game update logic
};
\ No newline at end of file