Skip to content

Display class

Pegacraffft edited this page Nov 29, 2020 · 4 revisions

Display class

This class is used to create new displays for your program.

1. setFullScreen(boolean fullScreen)

This method is used to toggle between the full screen and the windowed mode. If not set, it'll be set to windowed.

Parameters:

boolean fullScreen: If set to true: full screen, if set to false: windowed.

Examples:

//create display:
Display display = Game.display("Game");
//set fullscreen:
display.setFullScreen(true);
//create display:
Display display = Game.display("Game");
//set windowed:
display.setFullScreen(false);

2. setSize(int width, int height)

This method is used to resize the window in the wanted dimension. If not set, it'll be set to 1280x720px.

If you want to set the width or the height separately, use setWidth(int width) or setHeight(int height).

Parameters:

int width: The width you want the window to be set to in pixels.

int height: The height you want the window to be set to in pixels.

Examples:

//create display:
Display display = Game.display("Game");
//resize the display to 800x800px
display.setSize(800, 800);

3. setBackgroundColor(Color bgColor)

This method is used to set the background color of the display. If not set, it'll be set to white.

Parameters:

Color bgColor: The color you want the background to be set to.

Examples:

//create display:
Display display = Game.display("Game");
//set the background color to gray:
display.setBackgroundColor(Color.gray)

4. makeResizable(boolean b)

This method is used to determine if the display should be resizable or not. If not set, the display will be resizable.

Parameters:

boolean b: If set to true: resizable, if set to false: not resizable.

Examples:

//create display:
Display display = Game.display("Game");
//make the display resizable:
display.makeResizable(true);
//create display:
Display display = Game.display("Game");
//make the display not resizable:
display.makeResizable(false);

5. setTitle(String name)

This method is used to change the display name that is shown in the window. If not set, it'll be "Age-Engine".

Parameters:

String name: The name that should be shown.

Examples:

//create display:
Display display = Game.display("Game");
//change the display name to "This is a display"
display.setTitle("This is a display");

6. attachScene(String alias)

This method is used to assign a scene to a window. The scene will than be shown in that window.

A window without a scene will be empty and will just show the background color.

Parameters:

String alias: The alias of the scene you want to assign.

Examples:

//create display:
Display display = Game.display("Game");
//register new scene object:
Game.addScene(new GameScene(), "Main");
//assign the scene to the display:
display.attachScene("Main");

Getter and setter:

getAttachedScene()

Returns the currently assigned scene.

bs()

Returns the used buffer strategy in the display.

getWidth()

Returns the current display width

getHeight()

returns the current display height.

Public variables:

keyListener

This variable is the keyListener of the display. To find out more about keyListers click here.

It is used if you want to interact with the keyboard in your program.

mouseListener

This variable is the mouseListener of the display. To find out more about mouseListener look up the documentation.

It is used if you want to interact with the mouse in your program.