pub struct TransitionManager {
pub tag: String,
pub stats: TransitionStats,
/* private fields */
}Expand description
Manages screen-to-screen visual transitions.
The game loop should:
- Call
start()to begin a transition - Call
tick(dt)each frame - Check
should_swap_state()to know when to swap game state - Call
acknowledge_swap()after swapping - Call
render_overlay()to get the overlay for rendering - Check
is_done()to know when the transition is complete
Fields§
§tag: StringCallback tag for identifying which transition this is.
stats: TransitionStatsPer-frame stats.
Implementations§
Source§impl TransitionManager
impl TransitionManager
pub fn new() -> Self
Sourcepub fn start(&mut self, transition: TransitionType)
pub fn start(&mut self, transition: TransitionType)
Start a new transition. Any in-progress transition is immediately replaced.
Sourcepub fn start_tagged(
&mut self,
transition: TransitionType,
tag: impl Into<String>,
)
pub fn start_tagged( &mut self, transition: TransitionType, tag: impl Into<String>, )
Start a transition with a tag for identification.
Sourcepub fn start_with_easing(
&mut self,
transition: TransitionType,
easing: TransitionEasing,
)
pub fn start_with_easing( &mut self, transition: TransitionType, easing: TransitionEasing, )
Start a transition with custom easing.
Sourcepub fn capture_screen(&mut self, width: u32, height: u32, time: f32)
pub fn capture_screen(&mut self, width: u32, height: u32, time: f32)
Capture the current screen for cross-fade transitions.
Sourcepub fn should_swap_state(&self) -> bool
pub fn should_swap_state(&self) -> bool
Whether the game should swap state now.
Sourcepub fn acknowledge_swap(&mut self)
pub fn acknowledge_swap(&mut self)
Call after swapping game state to continue the fade-in phase.
Sourcepub fn is_active(&self) -> bool
pub fn is_active(&self) -> bool
Whether any transition is currently active (not None and not Completed).
Sourcepub fn state(&self) -> TransitionState
pub fn state(&self) -> TransitionState
Current transition state.
Sourcepub fn render_overlay(
&self,
_screen_w: f32,
_screen_h: f32,
) -> TransitionOverlay
pub fn render_overlay( &self, _screen_w: f32, _screen_h: f32, ) -> TransitionOverlay
Compute the overlay parameters for the current frame.
The renderer uses this to draw the transition effect on top of the scene.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TransitionManager
impl RefUnwindSafe for TransitionManager
impl Send for TransitionManager
impl Sync for TransitionManager
impl Unpin for TransitionManager
impl UnsafeUnpin for TransitionManager
impl UnwindSafe for TransitionManager
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.