Expand description
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 use ggez’s built in event loop, you can
write your own mainloop and check for events on your own. This is
not particularly hard, there’s nothing special about the
EventHandler trait. It just tries to simplify the process a
little. For examples of how to write your own main loop, see the
source code for this module, or the eventloop
example.
Re-exports§
pub use crate::input::gamepad::GamepadId;
Enums§
- Axis
- Gamepad’s elements which state can be represented by value from -1.0 to 1.0.
- Button
- Gamepad’s elements which state can be represented by value from 0.0 to 1.0.
- Error
Origin - Used in
EventHandler::on_error()to specify where an error originated
Traits§
- Event
Handler - A trait defining event callbacks. This is your primary interface with
ggez’s event loop. Implement this trait for a type and override at least theupdate()anddraw()methods, then pass it toevent::run()to run the game’s mainloop.
Functions§
- process_
device_ event - Feeds a
DeviceEventinto theContextso it can update any internal state it needs to, such as detecting mouse movements. If you are rolling your own event loop, you should call this on the events you receive before processing them yourself. - process_
event Deprecated - Feeds an
Eventinto theContextso it can update any internal state it needs to, such as detecting window resizes. If you are rolling your own event loop, you should call this on the events you receive before processing them yourself. - process_
window_ event - Feeds a
WindowEventinto theContextso it can update any internal state it needs to, such as detecting window resizes. If you are rolling your own event loop, you should call this on the events you receive before processing them yourself. - run
- Runs the game’s main loop, calling event callbacks on the given state object as events occur.