Code edit (3 edits merged)
Please save this source code
User prompt
For each block type in Block use a separate asset for createAsset rather than just 'block'
Code edit (1 edits merged)
Please save this source code
User prompt
In block, do not set tint where you currently do block.tint
User prompt
in cell do not set filled.tint
User prompt
Cache tint value on Cell using a self variable.
Remix started
Copy Block Puzzle
===================================================================
--- original.js
+++ change.js
@@ -19,15 +19,19 @@
var self = Container.call(this);
self.filled = false;
var empty = self.createAsset('cell', 'Filled with a cell (empty)', .5, .5);
empty.alpa = .8;
- var filled = self.createAsset('block', 'Filled with a block', .5, .5);
+ var filled;
empty.y = 2;
self.currentTint = 0xffffff;
- self.setFill = function (isFilled) {
+ self.setFill = function (isFilled, asset) {
self.filled = isFilled;
empty.visible = !self.filled;
- filled.visible = self.filled;
+ if (asset) {
+ if (isFilled) {
+ self.addChild(asset);
+ } else asset.destroy();
+ }
};
self.getTint = function () {
return self.currentTint;
};
@@ -102,8 +106,9 @@
for (var i = 0; i < self.shape.length; i++) {
for (var j = 0; j < self.shape[i].length; j++) {
if (self.shape[i][j] === 1) {
var block = self.createAsset('block', 'Block Graphics', .5, .5);
+ block.tint = self.color;
block.width = blockSize;
block.height = blockSize;
block.x = j * blockSize + blockOffsetX;
block.y = i * blockSize + blockOffsetY;
@@ -305,9 +310,9 @@
if (dragTarget) {
var cells = dragTarget.getOverlappingCells();
if (cells) {
for (var a = 0; a < cells.length; a++) {
- cells[a].setFill(true);
+ cells[a].setFill(true, dragTarget.blocks[a]);
cells[a].setTint(dragTarget.color);
}
blocks[blocks.indexOf(dragTarget)] = undefined;
dragTarget.destroy();
White square with tight 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 red Christmas decoration. Cartoon. Cute art style
Perfectly square yellow Christmas decoration. Cartoon style. Cute art style. Simple vector style.
Perfectly square bright blue Christmas decoration with cute happyy face. 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 green Christmas decoration with cute happyy face. Cartoon style. Cute art style. Simple vector style. No Shadows
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.