Class: Events
Defined in: adventure/Events.js, line 12
We only fire a few events, all at the beginning and end of a turn:
inputEnter
,
inputParseBegin
,
inputParseComplete
, and
inputQueueNext
(which fires between queued inputs).
Authors can hook into these to run custom code.
For example, you could write a series of random in-game background
events tied to specific Rooms,
to print additional text to the Display
after parsing has completed.
Example:
MyGame.reactor.addEventListener('inputParseComplete', function()
{
var random = Math.random() * 100;
switch (MyGame.world._currentRoom.name)
{
case "Frigid Wastes":
if( random < 10 )
{
MyGame.print(
"You're struck by a flash of blinding light as
sunlight reflects off the packed ice.", "random"
);
}
break;
case "Desert Wastes":
if( random > 5 && random < 10 )
{
MyGame.print(
"Heat haze shimmers off the distant dunes.", "random"
);
}
else if( random > 10 && random < 15 )
{
MyGame.print(
"You feel the sand shift beneath your feet.", "random"
);
}
break;
}
});
Private Constructor:
var foo = new adventurejs.Events(game)
Parameters:
-
game
Game
A reference to the game instance.
- Index
- Methods
- Properties
Index
Methods Collapse all |
Properties |
game :Object
Defined in: adventure/Events.js, line 66
Default value: {}
inputEnter :Event
Defined in: adventure/Events.js, line 73
inputParseBegin :Event
Defined in: adventure/Events.js, line 80
inputParseComplete :Event
Defined in: adventure/Events.js, line 87
inputQueueNext :Event
Defined in: adventure/Events.js, line 94