-
Notifications
You must be signed in to change notification settings - Fork 1
Create a button
Julien Tauran edited this page Dec 27, 2018
·
3 revisions
A button is defined as an object named "bs_button_t".
It can contains five events:
- Click pressed:
click_pressed_event - Click released:
click_released_event - Hover event:
hover_event - Hover in:
hover_in_event - Hover out:
hover_out_event
To attach an event to it, you will have to create a function with the name you want but with the required argument.
In this example we will attach a click pressed event.
void click_button(bs_event_button_click_pressed_t event)
{
bs_button_t *button = event.button;
bs_button_set_pos(event.button, 0, 0);
}
button->click_pressed_event = &click_button;
It supports three texture:
- Base texture:
texture_base - Hover texture:
texture_hover - Clicked texture:
texture_clicked
bs_button_set_texture_base(button, "pathtotexture/image.png");
It supports three sound:
- Click sound:
sound_click - Hover in sound:
sound_hover_in - Hover out sound:
sound_hover_out
bs_button_set_sound_click(button, "pathtosound/sound.ogg");
To create it you will have to choose an id (must be unique), a width and an height.
bs_button_t *button = bs_button_create("button id", 400, 200);
To add it to a scene.
bs_button_add_to_scene(scene, button);