spinnerbox Posted March 20, 2015 Share Posted March 20, 2015 I am struggling to disable my level buttons. I have 7 levels and apart from the first one I need to disable mouse events on buttons 2..7. I made a "for" cycle to generate my buttons, as I will have up to 21 levels, which is going to make my code better looking. Here is my "for" cycleboxes = [];numOfBoxes = 7;for (i = 0; i < numOfBoxes; i += 1) { box = gameObject.add.button(offsetXPos + startXPos * i, 40, wml.ImageAssetKeys['BOX' + (i + 1) + '_SHEET'], clickEvent, this, 2, 1, 1); box.frame = 0; // disabled state frame box.inputEnabled = false; box.input.enabled = false; boxes.push(box); this.screenObjects.add(boxes[i]);}So what this code manages to do is to set the frame to 0 but mouse events still enabled, i.e I can hover over the buttons and click them. I have the feeling that those input.enabled commands are not running thoroughly since if I run the code again the buttons get disabled. What is the problem? Is this a bug? And why there are two ways to disable input, inputEnabled and input.enabled? Link to comment Share on other sites More sharing options...
spinnerbox Posted March 20, 2015 Author Share Posted March 20, 2015 Best solution, add another "for" loop to disable buttonsfor (i = 0; i < numOfBoxes; i += 1) { boxes[i].frame = 0; boxes[i].inputEnabled = false; boxes[i].input.enabled = false; } Link to comment Share on other sites More sharing options...
Recommended Posts