pub struct AnimationPlayer { /* private fields */ }Expand description
Plays a move animation, stepping through its command sequence.
The player is a state machine:
start(move_id)loads the move’s command list.tick()advances one step and returns what happened.- After each tick,
oam_entries()has the current sprite data.
The caller is responsible for:
- Rendering OAM entries to the screen each frame.
- Applying
AnimEffectactions (palette changes, screen shake, etc.). - Counting down
WaitDelayframes before calling tick again.
Implementations§
Source§impl AnimationPlayer
impl AnimationPlayer
Sourcepub fn start(&mut self, move_id: usize, player_is_attacker: bool)
pub fn start(&mut self, move_id: usize, player_is_attacker: bool)
Start playing the animation for the given move.
move_id is 0-based index into MOVE_ANIM_DATA.
player_is_attacker determines Enemy transform resolution.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Whether the animation has finished playing.
Sourcepub fn oam_entries(&self) -> &[SpriteOamEntry]
pub fn oam_entries(&self) -> &[SpriteOamEntry]
Get the current OAM buffer for rendering.
Sourcepub fn current_tileset(&self) -> Option<u8>
pub fn current_tileset(&self) -> Option<u8>
Current move-animation tileset index (0/1/2) while a subanimation is active.
Sourcepub fn decode_command(raw: &(u8, u8, u8, u8)) -> AnimCommand
pub fn decode_command(raw: &(u8, u8, u8, u8)) -> AnimCommand
Decode a raw command tuple from MOVE_ANIM_DATA into an AnimCommand.
Sourcepub fn resolve_transform(
&self,
raw_transform: SubAnimTransform,
) -> SubAnimTransform
pub fn resolve_transform( &self, raw_transform: SubAnimTransform, ) -> SubAnimTransform
Resolve the effective transform for a subanimation, accounting for Enemy type and whose turn it is.
Source§impl AnimationPlayer
impl AnimationPlayer
Sourcepub fn render_frame_block(
frame_block_id: usize,
base_coord_id: usize,
transform: SubAnimTransform,
dest: &mut Vec<SpriteOamEntry>,
)
pub fn render_frame_block( frame_block_id: usize, base_coord_id: usize, transform: SubAnimTransform, dest: &mut Vec<SpriteOamEntry>, )
Render a frame block into OAM entries, applying the given transform.
frame_block_id: index into FRAME_BLOCK_DATA.
base_coord_id: index into BASE_COORDS.
transform: the resolved SubAnimTransform to apply.
dest: output buffer to append OAM entries to.
Source§impl AnimationPlayer
impl AnimationPlayer
Sourcepub fn tick(&mut self) -> AnimTickResult
pub fn tick(&mut self) -> AnimTickResult
Advance the animation by one step.
Returns what happened this tick. The caller should:
Playing→ renderoam_entries()to screen.WaitDelay→ waitframesframes, then call tick again.Effect→ apply the special effect, then call tick again.Done→ animation is finished.Playing/WaitDelayalso carry ahookwhen the current animation id has an entry in ANIMATION_ID_HOOKS (the original’s DoSpecialEffectByAnimationId, run after every DrawFrameBlock).
Source§impl AnimationPlayer
impl AnimationPlayer
Sourcepub fn apply_effect(effect: SpecialEffect) -> AnimEffect
pub fn apply_effect(effect: SpecialEffect) -> AnimEffect
Map a SpecialEffect to a high-level AnimEffect the caller should apply.
This translates the original ASM effect handlers into abstract operations. The caller’s rendering layer is responsible for executing these.
Trait Implementations§
Source§impl Clone for AnimationPlayer
impl Clone for AnimationPlayer
Source§fn clone(&self) -> AnimationPlayer
fn clone(&self) -> AnimationPlayer
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AnimationPlayer
impl Debug for AnimationPlayer
Auto Trait Implementations§
impl Freeze for AnimationPlayer
impl RefUnwindSafe for AnimationPlayer
impl Send for AnimationPlayer
impl Sync for AnimationPlayer
impl Unpin for AnimationPlayer
impl UnsafeUnpin for AnimationPlayer
impl UnwindSafe for AnimationPlayer
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.