on_level
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.
Type
Event
Edition
A7
Example (lite-C):
// display a blue loading bar
PANEL* pLoadBar = { layer = 9999; }
function eventLevel(percent)
{
set(pLoadBar,SHOW | LIGHT); // switch load bar on
vec_set(pLoadBar.blue,vector(255,200,200));
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
}
}
function main()
{
...
on_level = eventLevel;
level_load("mylevel.wmb");
...
}
See also:
on_close, on_client, on_server, on_load,
on_exit, level_load
► latest
version online