Code edit (5 edits merged)
Please save this source code
User prompt
add an onDestroy function in the block class that destroys the self.lightCOntainer
User prompt
in the blockRow class add an onDestroy function that calls the callDestroy function on all its children
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'ReferenceError: y is not defined' in or related to this line: 'y += rowSpeed;' Line Number: 212
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'x is not defined' in or related to this line: 'makeGlow(x, BLOCK_SIZE / 2 + BLOCK_MARGIN / 4);' Line Number: 296
Code edit (1 edits merged)
Please save this source code
User prompt
add a tween for each glow instance created in the onLit function of the block class. It should go from alpha 0 to 1 over 500ms
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: parent is undefined' in or related to this line: 'self.lightContainer.x = self.x + parent.x;' Line Number: 269
Code edit (3 edits merged)
Please save this source code
User prompt
Please fix the bug: 'self.lightContainer is undefined' in or related to this line: 'self.y = Math.sin(LK.ticks * LAVA_BOB_PERIOD + config.index * LAVA_BOB_OFFSET) * LAVA_BOB_HEIGHT;' Line Number: 158
User prompt
Please fix the bug: 'self.lightContainer is undefined' in or related to this line: 'self.lightContainer.removeChildren();' Line Number: 279
User prompt
Please fix the bug: 'self.parent is null' in or related to this line: 'self.lightContainer = lightManager.addChild(new ConfigContainer({' Line Number: 248
User prompt
Please fix the bug: 'self.parent is null' in or related to this line: 'self.lightContainer = lightManager.addChild(new ConfigContainer({' Line Number: 248
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Point is not a constructor' in or related to this line: 'var lightPosition = self.toGlobal(new Point());' Line Number: 248
User prompt
Please fix the bug: 'e is undefined' in or related to this line: 'var lightPosition = self.toGlobal();' Line Number: 248
Code edit (11 edits merged)
Please save this source code
User prompt
Please fix the bug: 'Point is not a constructor' in or related to this line: 'self.lightContainer = lightManager.addChild(new ConfigContainer({' Line Number: 248
User prompt
In the block class, set the lightContainer x and y position to be the global position of the block
Code edit (1 edits merged)
Please save this source code
Code edit (6 edits merged)
Please save this source code
User prompt
before calling the onFinish callback in the Light class's tween, check that it is attached to a parent
===================================================================
--- original.js
+++ change.js
@@ -68,25 +68,23 @@
});
var Light = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
var lightShape = self.attachAsset('shapeEllipse', {
- width: BLOCK_SIZE,
- height: BLOCK_SIZE,
+ y: -LIGHT_OFFSET,
+ width: BLOCK_SIZE - 2 * LIGHT_OFFSET,
+ height: BLOCK_SIZE - 2 * LIGHT_OFFSET,
anchorX: 0.5,
anchorY: 1,
scaleX: 0,
- scaleY: 0,
- alpha: 0
+ scaleY: 0
});
tween(lightShape, {
- alpha: 1,
scaleX: 1,
scaleY: 1
}, {
duration: LIGHT_GROW_SPEED,
onFinish: function onFinish() {
if (self.parent) {
- // Check if the Light is attached to a parent
config.callback();
}
}
});
@@ -107,9 +105,8 @@
anchorY: 0,
tint: 0xFF4D00
});
self.addChild(new Glow({
- asset: 'shapeBox',
anchorX: 0.5,
anchorY: 0.75,
height: 20,
rangeY: 150,
@@ -139,9 +136,9 @@
var layerAlpha = 1 / layers;
var widthStep = (config.rangeX || 0) * layerAlpha;
var heightStep = (config.rangeY || 0) * layerAlpha;
for (var i = 0; i < layers; i++) {
- self.attachAsset(config.asset || 'shapeEllipse', {
+ self.attachAsset(config.asset || 'shapeBox', {
width: config.width + widthStep * i,
height: config.height + heightStep * i,
anchorX: config.anchorX,
anchorY: config.anchorY,
@@ -192,9 +189,8 @@
var Block = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
var isRotating = false;
self.orientation = config.orientation !== undefined ? config.orientation : Math.floor(4 * Math.random());
- self.lit = !!config.lit;
self.upPath = false;
self.rightPath = false;
self.downPath = false;
self.leftPath = false;
@@ -235,86 +231,92 @@
self.onLit = function () {
if (!self.lit && (self.upPath || self.downPath || self.leftPath || self.rightPath)) {
self.lit = true;
self.lightContainer.removeChildren();
- self.lightContainer.addChild(new Glow({
- width: BLOCK_SIZE - 10,
- height: BLOCK_SIZE - 10,
+ self.lightContainer.attachAsset('shapeEllipse', {
+ width: BLOCK_SIZE - 2 * LIGHT_OFFSET,
+ height: BLOCK_SIZE - 2 * LIGHT_OFFSET,
anchorX: 0.5,
- anchorY: 0.5,
- rangeX: 20,
- rangeY: 20,
- tint: 0xFFFFFF
- }));
+ anchorY: 0.5
+ });
+ if (self.upPath) {
+ self.lightContainer.addChild(new Glow({
+ y: -BLOCK_SIZE / 2 - BLOCK_MARGIN / 2,
+ width: LIGHT_SPILL_SIZE,
+ height: LIGHT_SPILL_SIZE,
+ anchorX: 0.5,
+ anchorY: 0.5,
+ rangeX: 20,
+ layers: 4,
+ tint: 0xFFFFFF
+ }));
+ }
self.onSettle();
}
};
self.onSettle = function () {
self.updatePaths();
if (self.lit) {
- if (self.upPath && self.upBlock && !self.upBlock.lit) {
+ if (self.upPath && self.upBlock && self.upBlock.downPath && !self.upBlock.lit) {
self.upBlock.lightContainer.addChild(new Light({
y: BLOCK_HALFSIZE,
rotation: 0,
callback: self.upBlock.onLit
}));
}
- if (self.rightPath && self.rightBlock && !self.rightBlock.lit) {
+ if (self.rightPath && self.rightBlock && self.rightBlock.leftPath && !self.rightBlock.lit) {
self.rightBlock.lightContainer.addChild(new Light({
x: -BLOCK_HALFSIZE,
rotation: Math.PI / 2,
callback: self.rightBlock.onLit
}));
}
- if (self.downPath && self.downBlock && !self.downBlock.lit) {
+ if (self.downPath && self.downBlock && self.downBlock.upPath && !self.downBlock.lit) {
self.downBlock.lightContainer.addChild(new Light({
y: -BLOCK_HALFSIZE,
rotation: Math.PI,
callback: self.downBlock.onLit
}));
}
- if (self.leftPath && self.leftBlock && !self.leftBlock.lit) {
+ if (self.leftPath && self.leftBlock && self.leftBlock.rightPath && !self.leftBlock.lit) {
self.leftBlock.lightContainer.addChild(new Light({
x: BLOCK_HALFSIZE,
rotation: 3 * Math.PI / 2,
callback: self.leftBlock.onLit
}));
}
} else {
- if (self.upPath && self.upBlock && self.upBlock.lit) {
+ if (self.upPath && self.upBlock && self.upBlock.downPath && self.upBlock.lit) {
self.lightContainer.addChild(new Light({
y: -BLOCK_HALFSIZE,
- rotation: 0,
+ rotation: Math.PI,
callback: self.onLit
}));
}
- if (self.rightPath && self.rightBlock && self.rightBlock.lit) {
+ if (self.rightPath && self.rightBlock && self.rightBlock.leftPath && self.rightBlock.lit) {
self.lightContainer.addChild(new Light({
- x: -BLOCK_HALFSIZE,
- rotation: Math.PI / 2,
+ x: BLOCK_HALFSIZE,
+ rotation: 3 * Math.PI / 2,
callback: self.onLit
}));
}
- if (self.downPath && self.downBlock && self.downBlock.lit) {
+ if (self.downPath && self.downBlock && self.downBlock.upPath && self.downBlock.lit) {
self.lightContainer.addChild(new Light({
y: BLOCK_HALFSIZE,
- rotation: Math.PI,
+ rotation: 0,
callback: self.onLit
}));
}
- if (self.leftPath && self.leftBlock && self.leftBlock.lit) {
+ if (self.leftPath && self.leftBlock && self.leftBlock.rightPath && self.leftBlock.lit) {
self.lightContainer.addChild(new Light({
- x: BLOCK_HALFSIZE,
- rotation: 3 * Math.PI / 2,
+ x: -BLOCK_HALFSIZE,
+ rotation: Math.PI / 2,
callback: self.onLit
}));
}
}
};
self.updatePaths = function () {};
- if (self.lit) {
- self.onLit();
- }
return self;
});
var BlockX = Block.expand(function (config) {
var self = Block.call(this, config);
@@ -458,8 +460,10 @@
var BLOCK_MARGIN = 20;
var BLOCK_HALFSIZE = BLOCK_SIZE * 0.5;
var BLOCK_ROTATE_SPEED = 100;
var LIGHT_GROW_SPEED = 5000;
+var LIGHT_SPILL_SIZE = 25;
+var LIGHT_OFFSET = 5;
var ROW_SPAN = 7;
var ROW_COUNT = 11;
var blockManager = game.addChild(new BlockManager());
var lava = game.addChild(new Lava({
background
Music
light
Sound effect
rotate
Sound effect
error
Sound effect
crack
Sound effect
break
Sound effect
flow
Sound effect
bubble1
Sound effect
bubble2
Sound effect
bubble3
Sound effect
bubble4
Sound effect
bubble5
Sound effect
gong
Sound effect