The on_level event is triggered periodically during a level_load call in time intervals of about 20 ms. It can be used to display a progress bar or animation on a panel while loading huge levels. It gets a percentage value as an argument, which is 0 at the first call, and 100 at the last call when level loading is finished. The time_step variable is updated during level loading, and can be used to determine the time since the last on_level execution.


The on_level_load event is triggered when the level loading is complete, and can be used for initializing static level entities f.i. as obstacles for a physics engine. A7.85



Example (lite-C):

// display a blue loading bar when a level is loaded

PANEL* pLoadBar = { layer = 9999; }
function on_level_event(percent)
  set(pLoadBar,SHOW | LIGHT);   // switch load bar on
  pLoadBar.pos_x = 50;
  pLoadBar.pos_y = 50;
  pLoadBar.size_x = 10 + 3 * percent;   // 10..310 pixels
  pLoadBar.size_y = 10;
  if (percent >= 100) {  // level loading finished
wait(-1.0); // display the load bar for one further second reset(pLoadBar,SHOW); // switch it off } }

See also:

on_close, on_client, on_server, on_load, on_exit, on_ent_remove, level_load

► latest version online