User prompt
Fix Bug: 'Error: The supplied DisplayObject must be a child of the caller' in this line: 'self.visible = false;' Line Number: 15
User prompt
Fix Bug: 'Error: The supplied DisplayObject must be a child of the caller' in this line: 'self.visible = false;' Line Number: 16
User prompt
Fix Bug: 'Error: The supplied DisplayObject must be a child of the caller' in this line: 'self.visible = false;' Line Number: 17
User prompt
Fix Bug: 'ReferenceError: settingsBackground is not defined' in this line: 'self.visible = false;' Line Number: 17
User prompt
z-index the newly spawned individual objects so that they are behind the settings menu
User prompt
Fix Bug: 'TypeError: game.getChildByName is not a function' in this line: 'var object3 = game.getChildByName('object3');' Line Number: 74
User prompt
Fix Bug: 'TypeError: game.getChildByName is not a function' in this line: 'var object2 = game.getChildByName('object2');' Line Number: 55
User prompt
Fix Bug: 'TypeError: game.getChildByName is not a function' in this line: 'var object1 = game.getChildByName('object1');' Line Number: 36
User prompt
add object1 object2 and object3 only appear when setting1 setting2 and setting3 are activated
===================================================================
--- original.js
+++ change.js
@@ -36,9 +36,9 @@
var object1 = getChildByName(game, 'object1');
if (self.isSelected) {
setGameSetting('setting1', true);
if (!object1) {
- object1 = game.addChild(new Object1());
+ object1 = game.addChildAt(new Object1(), game.getChildIndex(settingsBackground));
object1.name = 'object1';
object1.x = 2048 / 2;
object1.y = 2732 / 2 - 450;
}
@@ -55,9 +55,9 @@
var object2 = getChildByName(game, 'object2');
if (self.isSelected) {
setGameSetting('setting2', true);
if (!object2) {
- object2 = game.addChild(new Object2());
+ object2 = game.addChildAt(new Object2(), game.getChildIndex(settingsBackground));
object2.name = 'object2';
object2.x = 2048 / 2;
object2.y = 2732 / 2 - 300;
}
@@ -74,9 +74,9 @@
var object3 = getChildByName(game, 'object3');
if (self.isSelected) {
setGameSetting('setting3', true);
if (!object3) {
- object3 = game.addChild(new Object3());
+ object3 = game.addChildAt(new Object3(), game.getChildIndex(settingsBackground));
object3.name = 'object3';
object3.x = 2048 / 2;
object3.y = 2732 / 2 - 150;
}
@@ -140,9 +140,9 @@
* When the cogwheels are tapped, we toggle the visibility of the settings menu.
*/
var setting1, setting2, setting3;
cogwheelGraphics.on('down', function () {
- game.addChild(settingsBackground);
+ game.addChildAt(settingsBackground, game.children.length);
console.log('Settings cogwheel tapped');
settingsBackground.visible = !settingsBackground.visible;
settingsBackground.x = 2048 / 2;
settingsBackground.y = 2732 / 2;