Button – Giavapps Controller

 

Giavapps Controller Button Initialization

 

gc_button_init(X, Y, KeyboardButton, GamepadButton, Sprite) Initializes all local variables for the button controller.

X: x position of the button controller.
Y: y position of the button controller.
KeyboardButton: keyboard key to assign to the button controller.
GamepadButton: gamepad input to assign to the button controller.
Sprite: sprite image of the button controller. This image will be also used as mask_index for collision checking.

Once you’ve initialized a GameMaker: Studio Object with this function you gain access to the following local variables:

visible indicates if the button controller should be visible or not. Mouse Clicks and Touch Inputs will be ignored when the button controller is invisible but Keyboard Keys and Gamepad Inputs will be still detected.

x x position of the button controller.

y y position of the button controller.

keyboard_button keyboard key assigned to the button controller.

gamepad_button gamepad input assigned to the button controller.

gamepad_device Indicates the gamepad device "slot". (Default Value: 0)

sprite sprite image of the button controller.

mask_index collision mask. This should be the same as sprite image usually.

press indicates if the button controller is held down (true) or not (false). (Default Value: false)

pressed indicates if the button controller has been pressed (true) or not (false). (Default Value: false)

released indicates if the button controller has been released (true) or not (false). (Default Value: false)

 

Giavapps Controller Button Functions

 

gc_button_alarm0() Updates pressure states of the button controller. This function must be called inside the Alarm 0 Event of the button controller.

 

gc_button_step() Updates the button controller. This function must be called inside the Step Event of the button controller.

 

gc_button_draw_gui() Draws the button controller on the GUI Layer. This function must be called inside the Draw GUI Event of the button controller.

 

Giavapps Controller Button Sprites

 

giavapps-controller-stick-sprite

 

Giavapps Controller Button Sprites can be any size of your choice (we used a 160×160 pixels for Sprite image) but you should remember centering the origin of the sprite (if needed) and marking Precise Collision Checking box for precise collision checking. The Sprite argument of gc_button_init() function also defines the mask_index used for collision checking.

 

Code Examples

 

Creating a Giavapps Controller Button

 

Create Event

 

gc_button_init(view_wview[0]-560, view_hview[0]-160, ord(‘X’), gp_face2, sprite_giavapps_controller_button_1);//initializes all local variables for the button controller

 

Alarm 0 Event

 

gc_button_alarm0();//updates pressure states of the button controller

 

Step Event

 

gc_button_step();//updates the button controller

 

Draw GUI Event

 

gc_button_draw_gui();//draws the button controller

 

Using Giavapps Controller Button States

 

Step Event

 

var button = GiavappsControllerButton;//sets a temporary variable to the button controller object

if(button.pressed)
{
show_debug_message("Giavapps Controller Button has been pressed!");
}
else if(button.released)
{
show_debug_message("Giavapps Controller Button has been released!");
}

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Leave a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

*