Module ggez::event [] [src]

The event module contains traits and structs to actually run your game mainloop and handle top-level state, as well as handle input events such as keyboard and mouse.

If you don't want to do this, you can write your own mainloop and get the necessary event machinery by calling context.sdl_context.event_pump() on your Context. You can then call whatever SDL event methods you want on that. This is not particularly elegant and is not guaranteed to be stable across different versions of ggez (for instance, we may someday get rid of SDL2), but trying to wrap it up more conveniently really ends up with the exact same interface.

See the eventloop example for an implementation.

Structs

EventPollIterator

An iterator that calls EventPump::poll_event().

Events

A handle to access the OS's event pump.

Mod
MouseState

Enums

Axis
Button
Event

Different event types.

Keycode
MouseButton

Constants

CAPSMOD
LALTMOD
LCTRLMOD
LGUIMOD
LSHIFTMOD
MODEMOD
NOMOD
NUMMOD
RALTMOD
RCTRLMOD
RESERVEDMOD
RGUIMOD
RSHIFTMOD

Traits

EventHandler

A trait defining event callbacks; your primary interface with ggez's event loop. Have a type implement this trait and override at least the update() and draw() methods, then pass it to event::run() to run the game's mainloop.

Functions

run

Runs the game's main loop, calling event callbacks on the given state object as events occur.