Module pix_engine::state
source · Expand description
PixState
methods for the Engine
and PixEngine
.
PixState
is the global engine state and API for any application using pix-engine
. A mutable
reference is passed to most PixEngine
methods and allows you to modify settings, query engine
and input state, as well as drawing to the current render target.
The most common use of PixState
is in the PixEngine::on_update
method.
See the Getting Started section and the PixState
page for the list
of available methods.
Provided PixState
methods:
PixState::title
: Current window title.PixState::set_title
: Set new window title.PixState::mouse_pos
: Mouse position this frame.PixState::pmouse_pos
: Mouse position previous frame.PixState::mouse_pressed
: Whether any Mouse button was pressed this frame.PixState::mouse_clicked
: Whether a given Mouse button was clicked this frame.PixState::mouse_down
: Whether a given Mouse button was pressed this frame.PixState::mouse_buttons
: AHashSet
of Mouse buttons pressed this frame.PixState::key_pressed
: Whether a given Key was pressed this frame.PixState::key_down
: Whether a given Key was pressed this frame.PixState::keys
: Whether any Key was pressed this frame.PixState::keymod_down
: Whether a given key modifier was pressed this frame.PixState::keymod
: TheKeyMod
s pressed this frame.
Example
fn on_update(&mut self, s: &mut PixState) -> PixResult<()> {
s.fill(s.theme().colors.primary);
s.rect([100, 0, 100, 100])?;
if s.button("Click me")? {
s.text("I was clicked!");
}
Ok(())
}
Modules
Structs
- Represents all state and methods for updating and interacting with the
Engine
.