altergo Posted May 24, 2014 Share Posted May 24, 2014 Hi, I want to make a simple quiz game. I take an questions from array, and mix the option answers. Here is a function which creates a group of buttons: function addVariantsHtml(id) { var answer = new Array(); answer = getAnswersVariants(id); all_buttons = game.add.group(); for (var i = 0; i < 5; i++) { var button = game.add.button((100+30*i), (400+5*i), 'buttons', actionOnClick, this, 1, 0, 2); button.name = "button"+i; button.value = answer['trans']; button.char_id = answer['id']; var style = { font: "10px Arial", fill: "#000000", align: "center" }; var text = game.add.text(0, 0, answer['trans'], style); button.addChild(text); all_buttons.add(button); } } After every answer i call all_buttons.removeAll(); to delete the buttons, but the problem is that my addVariantsHtml create five inputHandlers (actionOnClick) Here is my questions:1.Is it a right way to create a group of buttons?2. What is the right way to delete ellements with unused handlers? Thanks, Link to comment Share on other sites More sharing options...
Recommended Posts