Game Development Reference
In-Depth Information
'
Teapot Wars, the level files exist are created in the Dev/Assets/World directory. Here
s
an example of a level file:
<World>
<!-- A list of static actors to load. Static actors have no
game view attached. This is for stuff like level geometry.- ->
<StaticActors>
<Actor resource=
actors\grid.xml
/>
<Actor resource=
actors\light.xml
/>
<Actor resource=
actors\afternoon_sky.xml
/>
<Actor resource=
actors\music.xml
/>
</StaticActors>
<Script preLoad=
scripts\LevelInit.lua
postLoad=
scripts\LevelPostInit.lua
/>
</World>
The first block defines all of the static actors, which have no game view. The grid
geometry, lights, the skybox, and even the background music are all stored as static
entities. The second block is the script configuration. This element defines a preload
script and a postload script. The preload script is executed as the very first thing dur-
ing a level load. The postload script happens at the very end. This is useful to get the
dependency order correct. These two scripts are the only scripts the level automati-
cally executes. Let
'
s take a look at the preload script:
require(
scripts\\ActorManager.lua
);
g_actorMgr = ActorManager:Create();
function AddPlayer(scriptObject)
g_actorMgr:AddPlayer(scriptObject);
end
function RemovePlayer(scriptObject)
g_actorMgr:RemovePlayer(scriptObject);
end
function AddEnemy(scriptObject)
g_actorMgr:AddEnemy(scriptObject);
end
function RemoveEnemy(scriptObject)
g_actorMgr:RemoveEnemy(scriptObject);
end
Search WWH ::




Custom Search