-
Notifications
You must be signed in to change notification settings - Fork 0
Buttons
zenith391 edited this page Jan 3, 2019
·
2 revisions
Here is an example about creating buttons, which are based on GameObject. The method only slightly changes between thoses objects. First you need to add a code before the main() method:
Button hello = new Button("text");After you did that you need to import: org.powerhigh.objects.Button;
Add in the init() method:
hello.setSize(100, 70); //Setting size to the BUTTON
hello.setColor(Color.GREEN); // Setting a COLOR to OUR button
//Setting the position of the BUTTON
hello.setX(100);
hello.setY(100);
// The action will be executed when the button is clicked.
hello.addAction(() -> {
System.out.println("Hello! I am a button."); // Example code
}
);
win.add(hello);If you don't see your button, you might have skipped something and you need to take a look at the following tutorial: Using Components