===================================================================
--- original.js
+++ change.js
@@ -1,77 +1,7 @@
/****
* Classes
-****/
-var Particle = Container.expand(function (tint) {
- var self = Container.call(this);
- self.tint = tint;
- var particleGraphics = self.attachAsset('particle', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- particleGraphics.rotation = Math.random() * Math.PI * 2;
- particleGraphics.tint = self.tint;
- self.vx = Math.random() * 4 - 2;
- self.vy = Math.random() * 4 - 2;
- self.alpha = 1;
- self.lifetime = 60;
- self.tick = function () {
- self.x += self.vx;
- self.y += self.vy;
- self.alpha -= 1 / self.lifetime;
- if (self.alpha <= 0) {
- self.destroy();
- }
- };
-});
-var Cell = Container.expand(function () {
- var self = Container.call(this);
- self.filled = false;
- var yOffsetArray = [-25, -10, -20, -25, -25, -20];
- var empty = self.attachAsset('cell', {
- anchorX: 0.5,
- anchorY: 0.5
- });
- empty.alpa = .8;
- var filled;
- var currentOffset;
- empty.y = 2;
- self.currentTint = 0xffffff;
- self.setFill = function (isFilled, asset, offset) {
- self.filled = isFilled;
- empty.visible = !self.filled;
- if (isFilled) {
- if (asset) {
- asset.x = 0;
- asset.y = yOffsetArray[offset] || -15;
- currentOffset = offset;
- self.addChild(asset);
- filled = asset;
- }
- } else {
- if (filled) {
- filled.destroy();
- filled = null;
- }
- }
- };
- self.tick = function (i, j) {
- if (filled) {
- var offset = Math.cos(((i + j) * 3 + LK.ticks / 2) / 6) / 20;
- var ty = yOffsetArray[currentOffset] || -15;
- filled.y = ty + Math.abs(offset * 200) - 5;
- filled.rotation = offset;
- }
- };
- self.getTint = function () {
- return self.currentTint;
- };
- self.setTint = function (tint) {
- self.currentTint = tint;
- empty.tint = tint;
- };
- self.setFill(false);
-});
+****/
var Block = Container.expand(function (board) {
var self = Container.call(this);
var hsvToRgb = function hsvToRgb(h, s, v) {
var r, g, b;
@@ -178,9 +108,9 @@
this.targetY += oy / 5;
this.x = currentX - this.targetX;
this.y = currentY - this.targetY;
};
- self.move = function (x, y) {
+ self._move_migrated = function (x, y) {
currentX = x;
currentY = y;
self.x = x - this.targetX;
self.y = y - this.targetY;
@@ -313,19 +243,89 @@
}
};
self.placeBlock = function () {};
});
+var Cell = Container.expand(function () {
+ var self = Container.call(this);
+ self.filled = false;
+ var yOffsetArray = [-25, -10, -20, -25, -25, -20];
+ var empty = self.attachAsset('cell', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ empty.alpa = .8;
+ var filled;
+ var currentOffset;
+ empty.y = 2;
+ self.currentTint = 0xffffff;
+ self.setFill = function (isFilled, asset, offset) {
+ self.filled = isFilled;
+ empty.visible = !self.filled;
+ if (isFilled) {
+ if (asset) {
+ asset.x = 0;
+ asset.y = yOffsetArray[offset] || -15;
+ currentOffset = offset;
+ self.addChild(asset);
+ filled = asset;
+ }
+ } else {
+ if (filled) {
+ filled.destroy();
+ filled = null;
+ }
+ }
+ };
+ self.tick = function (i, j) {
+ if (filled) {
+ var offset = Math.cos(((i + j) * 3 + LK.ticks / 2) / 6) / 20;
+ var ty = yOffsetArray[currentOffset] || -15;
+ filled.y = ty + Math.abs(offset * 200) - 5;
+ filled.rotation = offset;
+ }
+ };
+ self.getTint = function () {
+ return self.currentTint;
+ };
+ self.setTint = function (tint) {
+ self.currentTint = tint;
+ empty.tint = tint;
+ };
+ self.setFill(false);
+});
+var Particle = Container.expand(function (tint) {
+ var self = Container.call(this);
+ self.tint = tint;
+ var particleGraphics = self.attachAsset('particle', {
+ anchorX: 0.5,
+ anchorY: 0.5
+ });
+ particleGraphics.rotation = Math.random() * Math.PI * 2;
+ particleGraphics.tint = self.tint;
+ self.vx = Math.random() * 4 - 2;
+ self.vy = Math.random() * 4 - 2;
+ self.alpha = 1;
+ self.lifetime = 60;
+ self.tick = function () {
+ self.x += self.vx;
+ self.y += self.vy;
+ self.alpha -= 1 / self.lifetime;
+ if (self.alpha <= 0) {
+ self.destroy();
+ }
+ };
+});
/****
* Initialize Game
-****/
+****/
var game = new LK.Game({
backgroundColor: 0x000000
});
/****
* Game Code
-****/
+****/
var gameBackground = game.attachAsset('gameBackground', {
anchorX: 0.5,
anchorY: 0.5
});
@@ -343,26 +343,26 @@
block.y = 2732 + block.height;
block.setStartPosition(block.x, 2732 - block.height / 2 - 30);
blocks.push(block);
game.addChild(block);
- block.on('down', function (obj) {
+ block.on('down', function (x, y, obj) {
dragTarget = this;
- var pos = obj.event.getLocalPosition(this);
- var targetPos = obj.event.getLocalPosition(game);
+ var pos = this.toLocal(obj.global);
+ var targetPos = game.toLocal(obj.global);
this.targetX = pos.x;
this.targetY = pos.y;
- dragTarget.move(targetPos.x, targetPos.y);
+ dragTarget._move_migrated(targetPos.x, targetPos.y);
});
};
-game.on('move', function (obj) {
+game.on('move', function (x, y, obj) {
if (dragTarget) {
board.removeTint();
- var pos = obj.event.getLocalPosition(game);
- dragTarget.move(pos.x, pos.y);
+ var pos = game.toLocal(obj.global);
+ dragTarget._move_migrated(pos.x, pos.y);
dragTarget.showOverlap();
}
});
-game.on('up', function (obj) {
+game.on('up', function (x, y, obj) {
if (dragTarget) {
var cells = dragTarget.getOverlappingCells();
if (cells) {
for (var a = 0; a < cells.length; a++) {
@@ -395,15 +395,15 @@
var score = 0;
game.createBlocks();
var scoreTxt = new Text2('0', {
size: 150,
- fill: "#ffffff",
+ fill: 0xFFFFFF,
font: 'Impact',
stroke: '#2a636e',
strokeThickness: 16
});
scoreTxt.anchor.set(.5, 0);
-LK.gui.topCenter.addChild(scoreTxt);
+LK.gui.top.addChild(scoreTxt);
game.isMovePossible = function () {
for (var a = 0; a < blocks.length; a++) {
if (blocks[a]) {
for (var i = 0; i < 10; i++) {
White square with round corners, flat shaded, hyper casual game. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
White particle cloud. Cartoon. Bright outline. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Perfectly square yellow Christmas decoration. Cartoon style. Cute art style. Simple vector style.
Perfectly square bright purple Christmas decoration with cute happyy face. Cartoon style. Cute art style. Simple vector style.
Perfectly square bright dark blue Christmas decoration with cute happyy face. Cartoon style. Cute art style. Simple vector style.
Perfectly square bright cobalt blue Christmas decoration with cute happyy face. Cartoon style. Cute art style. Simple vector style. No Shadows Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Background for hyper casual puzzle game. Showing Santas workshop. Pastel colors, flat shaded, vector art. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Perfectly square bright green Christmas decoration with cute happyy face. Cartoon style. Cute art style. Simple vector style. No Shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.
Perfectly circle bright RED Christmas decoration with cute happyy face. Cartoon style. Cute art style. Simple vector style. No Shadows. Single Game Texture. In-Game asset. 2d. Blank background. High contrast. No shadows.