You need to make a lot of buttons to select the level. As in most games, tell me how it is implemented. I don’t think what is done on each button
- I read it 3 times, but, unfortunately, I did not understand what exactly you are interested in. Could you somehow concise your question, preferably with examples, and it would not be bad for you to say what exactly you want to achieve. - Alex Kapustin
|
2 answers
handler-listener of course is one, and you can find out which button is pressed in the following ways:
- (correct) to inherit the class of the button in its own, with the property containing the necessary data (public var levelData: LevelDataContainer;), in the cycle of creating the buttons, this property is filled and when the button is pressed, the handler receives all the necessary data
- fill in the mask of the name or id properties ("ButtonLevel_level_1_noncompleted"), when you click on parse it and receive data
- on the coordinates of the button, calculate the column and row, get the serial number of the button
- (economical, for iOS / Mobile) do not create buttons, draw their pictures in the sprite, highlight the desired Rect by hovering, coordinates also from click / tach coordinates.
- Here is the first method that is the most suitable for me, but I cannot find out how to get it from the handler (public var levelData: LevelDataContainer;) - Bruyn
|
private function clickHandler(event:MouseEvent):void { if ( event.target is MyButton) { var myButton:MyButton = event.target as Mybutton; var levelData:LevelData = myButton.levelData; } {
- I just found it myself and you answered it here. Thank you so much for not forgetting. - Bruyn
|