|
mouse clicks |
pr3ona
Member #16,105
October 2015
|
how do i get allegro to register multiple mouse clicks and then execute them. Please help attached is a copy of my main cpp file Many thanks |
Edgar Reynaldo
Major Reynaldo
May 2007
|
1al_install_mouse();
2
3ALLEGRO_EVENT_QUEUE* queue = al_create_event_queue();
4if (!queue) {return -1;}
5
6al_register_event_source(queue , al_get_mouse_event_source());
7
8//...
9
10// in program loop
11ALLEGRO_EVENT ev;
12
13while (al_get_next_event(queue , &ev)) {
14 if (ev.type == ALLEGRO_EVENT_MOUSE_DOWN) {
15 // mouse button pressed, do something
16 }
17}
My Website! | EAGLE GUI Library Demos | My Deviant Art Gallery | Spiraloid Preview | A4 FontMaker | Skyline! (Missile Defense) Eagle and Allegro 5 binaries | Older Allegro 4 and 5 binaries | Allegro 5 compile guide |
pr3ona
Member #16,105
October 2015
|
Hi Edgar Thank you for your reply:) |
duncan perham
Member #15,403
November 2013
|
Registering multiple clicks before the program updates is very bad to have it "waiting for a second click" before updating. best method is when you want two clicks is to set a flag, WaitingForSecondClick=true; Even when pausing a game, you should never actually pause the main event loop. Just the piece of code that you want paused... Another method would be to add in a small piece of code arround your get eventsarea, that stores time and position of last click, then if another click arrives in a similar position and time, you can pass that on as a double click. (or trebble if you want), or even mouse click combos. if you want it to ignore a single click event and pass a double clcik event, then you would need to delay the event cue for a few ticks so that it can determine if that click it just recieved was actually a double click. |
|