If i have 2 buttons or more in one class how i get witch button is clicked?
package
{
import net.flashpunk.World;
public class MAIN_GUI extends World
{
public function MAIN_GUI()
{
trace("world init");
add(new GUI_CLASS(4, 100, 30));
add(new GUI_CLASS(1, 125, 60));
add(new GUI_CLASS(3, 140, 100));
add(new GUI_CLASS(2, 165, 110));
add(new GUI_CLASS(5, 120, 20));
}
}
}
package { import flash.display.Graphics; import net.flashpunk.Entity; import net.flashpunk.graphics.Image; import net.flashpunk.FP; import net.flashpunk.utils.Input; import net.flashpunk.utils.Key; /** * … * @author Savvas */ public class GUI_CLASS extends Entity { [Embed(source = “…/GUI/BOX_IN_MAIN_GUI.png”)] private const MAIN__BOX:Class; private var mainboxsprite:Image = new Image(MAIN__BOX);
[Embed(source = "../GUI/EASY_BTN.png")]
private const EASY_BUTTON:Class;
private var easybuttonsprite:Image = new Image(EASY_BUTTON);
[Embed(source = "../GUI/EASY_BTN1.png")]
private const EASY_BUTTON1:Class;
private var easybutton1sprite:Image = new Image(EASY_BUTTON1);
[Embed(source = "../GUI/MAIN_GUI_BOX.png")]
private const GUIMAINBOX:Class;
private var guimainbox:Image = new Image(GUIMAINBOX);
[Embed(source = "../GUI/TITLE_MAIN_GUI.png")]
private const TITLE:Class;
private var title:Image = new Image(TITLE);
public function GUI_CLASS(getName:int, xpos:int, ypos:int)
{
if (getName == 1)
{
graphic = mainboxsprite;
}
if (getName == 2)
{
graphic = easybuttonsprite;
}
if (getName == 3)
{
graphic = easybutton1sprite;
setHitboxTo(graphic);
type = "easy_btn";
}
if (getName == 4)
{
graphic = guimainbox;
setHitboxTo(graphic);
type = "big_box";
}
if (getName == 5)
{
graphic = title;
}
x = xpos;
y = ypos;
}