本文整理汇总了C++中MyDialog::ProcessEvent方法的典型用法代码示例。如果您正苦于以下问题:C++ MyDialog::ProcessEvent方法的具体用法?C++ MyDialog::ProcessEvent怎么用?C++ MyDialog::ProcessEvent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyDialog
的用法示例。
在下文中一共展示了MyDialog::ProcessEvent方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
ALLEGRO_DISPLAY *display;
ALLEGRO_TIMER *tick_timer;
if (!al_init()) {
TRACE("Allegro init failed!\n");
return 1;
}
al_init_font_addon();
al_init_image_addon();
al_init_primitives_addon();
al_install_keyboard();
al_install_mouse();
display = al_create_display(640, 480);
if (!display) {
TRACE("Display init failed!\n");
return 1;
}
al_hide_mouse_cursor(display);
/* Must set this before calling InstallMASkinG() ! */
MAS::SetLogicRate(1.0 / 0.02);
/* MASkinG must be initialized after the display. */
if (InstallMASkinG("allegro.cfg") != MAS::Error::NONE ) {
TRACE("MA5kinG init failed!\n");
return 1;
}
tick_timer = al_create_timer(0.02);
queue = al_create_event_queue();
al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *) al_get_keyboard_event_source());
al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *) al_get_mouse_event_source());
al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *) display);
al_register_event_source(queue, (ALLEGRO_EVENT_SOURCE *) tick_timer);
// create a new dialog on the current display
MyDialog *dlg = new MyDialog();
al_start_timer(tick_timer);
/* You have to call this manually. */
dlg->Start();
while (!dlg->ShouldClose()) {
ALLEGRO_EVENT event;
al_wait_for_event(queue, &event);
switch (event.type) {
case ALLEGRO_EVENT_TIMER:
if (event.timer.source == tick_timer) {
dlg->DoTick();
/* Skip the drawing if we've got more events to process. */
if (!al_event_queue_is_empty(queue))
continue;
/* Redraw the screen */
al_clear_to_color(al_map_rgb(0, 0, 0));
dlg->Draw();
al_flip_display();
}
else
/* Oh, it must be the game timer. */
dlg->ProcessEvent(&event);
break;
default:
dlg->ProcessEvent(&event);
}
}
/* You have to call this manually. */
dlg->End();
// delete the dialog
delete dlg;
ExitMASkinG();
return 0;
}