User prompt
replace the scoretext text2 class with a borderedText
Code edit (12 edits merged)
Please save this source code
User prompt
for the +1 text2 class, replace it with a borderedText instance instead
Code edit (2 edits merged)
Please save this source code
User prompt
create an iconRotate at the same location as the iconGear
User prompt
display an iconGear near the rowSpeed display
User prompt
Update the initial label as well
User prompt
the rowSpeed display should be multiplied by 60 and show only 1 decimal place
User prompt
remove the "row speed" label, display only the value, and update it when calling adjustRowSpeed
User prompt
display the rowSpeed at the top-right of the screen, in a smaller font size than the score
Code edit (1 edits merged)
Please save this source code
Code edit (3 edits merged)
Please save this source code
User prompt
create a new, fullwidth, 10 height shapebox at the lightlevel
User prompt
create a fullwidth, 10 height shapebox at the lightlevel
Code edit (11 edits merged)
Please save this source code
User prompt
add a shapeBox after the lightManager. The shape should be full width, have a height of LIGHT_LEVEL and tinted black
Code edit (1 edits merged)
Please save this source code
User prompt
attach a iconLight asset at the top of the screen, with an orange tint
Code edit (1 edits merged)
Please save this source code
User prompt
add a variance of LIGHT_GROW_VARIANCE to the LIGHT_GROW_SPEED
Code edit (2 edits merged)
Please save this source code
User prompt
Please fix the bug: 'seetings is not defined' in or related to this line: 'settings.xs = (seetings.xs || 0) + 1;' Line Number: 823
Code edit (1 edits merged)
Please save this source code
User prompt
Please fix the bug: 'TypeError: blockClass is not a constructor' in or related to this line: 'var newBlock = self.parent.addChild(new blockClass({' Line Number: 637
Code edit (1 edits merged)
Please save this source code
===================================================================
--- original.js
+++ change.js
@@ -74,12 +74,11 @@
return self;
});
var PointText = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
- var text = self.addChild(new Text2("+1", {
+ var text = self.addChild(new BorderedText("+1", {
fill: 0xFFFFFF,
- stroke: 0x000000,
- strokeThickness: 4,
+ border: 0x000000,
size: 120
}));
text.anchor = {
x: 0.5,
@@ -183,8 +182,144 @@
});
}
return self;
});
+/**
+* var config = {
+* x : Number || 0, // See: ConfigContainer
+* y : Number || 0, // See: ConfigContainer
+* rotation : Number || 0, // See: ConfigContainer
+* anchorX : Number || 0,
+* anchorY : Number || 1,
+* size : Number || TEXT_DEFAULT_SIZE,
+* font : String || TEXT_DEFAULT_FONT,
+* fill : String || TEXT_DEFAULT_FILL,
+* border : String || TEXT_DEFAULT_BORDER,
+* }
+**/
+var BorderedText = ConfigContainer.expand(function (text, config) {
+ var self = ConfigContainer.call(this, config);
+ config = config || {};
+ var anchorX = config.anchorX !== undefined ? config.anchorX : 0;
+ var anchorY = config.anchorY !== undefined ? config.anchorY : 1;
+ var size = config.size !== undefined ? config.size : TEXT_DEFAULT_SIZE;
+ var font = config.font !== undefined ? config.font : TEXT_DEFAULT_FONT;
+ var textFill = config.fill !== undefined ? config.fill : TEXT_DEFAULT_FILL;
+ var borderFill = config.border !== undefined ? config.border : TEXT_DEFAULT_BORDER;
+ var mainAsset;
+ var textAssets = [];
+ ;
+ self.setText = setText;
+ self.setFill = setFill;
+ ;
+ function setText(newText) {
+ for (var i = 0; i < textAssets.length; i++) {
+ textAssets[i].setText(newText);
+ }
+ }
+ function setFill(newFill) {
+ textFill = newFill;
+ mainAsset.fill = newFill;
+ }
+ function buildTextAssets(newText) {
+ for (var i = 0; i < TEXT_OFFSETS.length; i++) {
+ var main = i === TEXT_OFFSETS.length - 1;
+ var textAsset = textAssets[i];
+ if (textAsset) {
+ textAsset.destroy();
+ }
+ textAsset = self.addChild(new Text2(newText, {
+ fill: main ? textFill : borderFill,
+ font: font,
+ size: size
+ }));
+ textAsset.anchor = {
+ x: anchorX,
+ y: anchorY
+ }; // NOTE: Cannot be set in config
+ textAsset.x = TEXT_OFFSETS[i][0] * TEXT_BORDER_WEIGHT; // NOTE: Cannot be set in config
+ textAsset.y = TEXT_OFFSETS[i][1] * TEXT_BORDER_WEIGHT; // NOTE: Cannot be set in config
+ textAssets[i] = textAsset;
+ }
+ mainAsset = textAssets[TEXT_OFFSETS.length - 1];
+ }
+ ;
+ buildTextAssets(text);
+ return self;
+});
+/**
+* var config = {
+* x : Number || 0, // See: ConfigContainer
+* y : Number || 0, // See: ConfigContainer
+* rotation : Number || 0, // See: ConfigContainer
+* anchorX : Number || .5,
+* anchorY : Number || .5,
+* scale : Number || undefined,
+* scaleX : Number || scale,
+* scaleY : Number || scale,
+* width : Number || undefined, // Auto-calculated if left undefined and height is set
+* height : Number || undefined, // Auto-calculated if left undefined and width is set
+* tint : String || 0xFFFFFF, // Not tinted by default
+* border : String || TEXT_DEFAULT_BORDER,
+* }
+**/
+var BorderedSymbol = ConfigContainer.expand(function (symbol, config) {
+ var self = ConfigContainer.call(this, config);
+ config = config || {};
+ var width = config.width !== undefined ? config.width : undefined;
+ var height = config.height !== undefined ? config.height : undefined;
+ var scale = config.scale !== undefined ? config.scale : undefined;
+ var scaleX = config.scaleX !== undefined ? config.scaleX : scale;
+ var scaleY = config.scaleY !== undefined ? config.scaleX : scale;
+ var anchorX = config.anchorX !== undefined ? config.anchorX : .5;
+ var anchorY = config.anchorY !== undefined ? config.anchorY : .5;
+ var symbolTint = config.tint !== undefined ? config.tint : 0xFFFFFF;
+ var borderTint = config.border !== undefined ? config.border : TEXT_DEFAULT_BORDER;
+ var mainSymbol;
+ var symbolAssets = [];
+ ;
+ self.setSymbol = buildSymbolAssets;
+ self.setTint = setTint;
+ ;
+ function setTint(newTint) {
+ // NOTE: Tinting is currently broken (cannot use string)
+ // mainSymbol.tint = newTint;
+ // symbolConfig.tint = newTint;
+ }
+ function buildSymbolAssets(newSymbol) {
+ for (var i = 0; i < TEXT_OFFSETS.length; i++) {
+ var main = i === TEXT_OFFSETS.length - 1;
+ var symbolAsset = symbolAssets[i];
+ if (symbolAsset) {
+ symbolAsset.destroy();
+ }
+ symbolAsset = self.attachAsset(newSymbol, {
+ // tint: main ? symbolTint : borderTint,
+ tint: main ? 0xFFFFFF : 0x000000,
+ // NOTE: Tinting is currently broken (cannot use string)
+ x: TEXT_OFFSETS[i][0] * TEXT_BORDER_WEIGHT,
+ y: TEXT_OFFSETS[i][1] * TEXT_BORDER_WEIGHT,
+ anchorX: anchorX,
+ anchorY: anchorY
+ });
+ if (width !== undefined && height === undefined) {
+ height = symbolAsset.height * (width / symbolAsset.width);
+ } else if (height !== undefined && width === undefined) {
+ width = symbolAsset.width * (height / symbolAsset.height);
+ }
+ symbolAsset.width = width;
+ symbolAsset.height = height;
+ if (scaleX !== undefined && scaleY !== undefined) {
+ symbolAsset.scale.set(scaleX, scaleY);
+ }
+ symbolAssets[i] = symbolAsset;
+ }
+ mainSymbol = symbolAssets[TEXT_OFFSETS.length - 1];
+ }
+ ;
+ buildSymbolAssets(symbol);
+ return self;
+});
var Border = ConfigContainer.expand(function (config) {
var self = ConfigContainer.call(this, config);
var radius = 70;
var totalHeight = 0;
@@ -635,8 +770,20 @@
/****
* Game Code
****/
+// Math constants / pre-calculations
+var MATH_HALF_ROOT_3 = Math.sqrt(3) / 2; // Required by: TEXT_OFFSETS, BorderedText, BorderedSymbol, SymbolText
+;
+// Text settings
+var TEXT_OFFSETS = [[0, 1], [MATH_HALF_ROOT_3, 0.5], [MATH_HALF_ROOT_3, -0.5], [0, -1], [-MATH_HALF_ROOT_3, -0.5], [-MATH_HALF_ROOT_3, 0.5], [0, 0]]; // Required by: BorderedText, BorderedSymbol, SymbolText
+var TEXT_BORDER_WEIGHT = 4; // Required by: BorderedText, BorderedSymbol, SymbolText
+var TEXT_DEFAULT_BORDER = '#000000'; // Required by: BorderedText, BorderedSymbol, SymbolText
+var TEXT_DEFAULT_FILL = '#FFFFFF'; // Required by: BorderedText, SymbolText
+var TEXT_DEFAULT_FONT = 'Arial'; // Required by: BorderedText, SymbolText
+var TEXT_DEFAULT_SIZE = 50; // Required by: BorderedText, SymbolText
+;
+// Other settings
var LAVA_LINE = game.height - 200;
var LAVA_SLICE_COUNT = 18;
var LAVA_SLICE_WIDTH = 128;
var LAVA_BOB_HEIGHT = 10;
@@ -681,14 +828,14 @@
fill: 0xFFFFFF,
stroke: 0x000000,
strokeThickness: 5
}));
-rowSpeedText.anchor.set(1, 0);
+rowSpeedText.anchor.set(1.0, -0.5);
var speedIcon = LK.gui.topRight.addChild(LK.getAsset('iconGear', {
- anchorX: 1,
- anchorY: 0,
- x: rowSpeedText.x - rowSpeedText.width - 10,
- y: rowSpeedText.y
+ anchorX: 0.5,
+ anchorY: 0.5,
+ x: rowSpeedText.x - rowSpeedText.width - 70,
+ y: rowSpeedText.height
}));
LK.gui.topRight.addChild(LK.getAsset('iconRotate', {
anchorX: 0.5,
anchorY: 0.5,
@@ -707,10 +854,9 @@
y: LIGHT_LEVEL,
width: game.width - 200,
height: 8,
anchorY: 0.6,
- alpha: 0.75,
- tint: 0xFF4D00
+ alpha: 0.75
}));
var leftBorder = game.addChild(new Border({
x: 30
}));
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