home *** CD-ROM | disk | FTP | other *** search
- #include "Animation2D.h"
- #include "Sequences.h"
-
- Animation2D::Animation2D(Scene2D * scene, int layer, const String & name )
- : Object2D( scene, layer ),
- sequences( Sequences::load( name, scene ) ),
- finished( true ),
- alpha( 255 )
- {
- }
-
- Animation2D::~Animation2D()
- {
- Sequences::unload( sequences );
- }
-
- void Animation2D::render()
- {
- sequences->render_frame( current_seq, current_fr, alpha );
- }
-
- void Animation2D::start(unsigned seq, bool is_loop)
- {
- current_seq = seq;
- current_fr = 0;
- time_ms = 0;
- loop_current = is_loop;
- finished = false;
- }
-
- bool Animation2D::life_cycle(unsigned delta_time_ms)
- {
- time_ms += delta_time_ms;
- while( time_ms > sequences->get_duration( current_seq, current_fr ) )
- {
- time_ms -= sequences->get_duration( current_seq, current_fr );
- ++current_fr;
- if( current_fr >= sequences->get_frame_count( current_seq ) )
- {
- if( loop_current )
- {
- current_fr = 0;
- }
- else
- {
- // ╬±≥αφεΓΦ≥ⁿ± φα ∩ε±δσΣφσ∞ ΩαΣ≡σ
- --current_fr;
- time_ms = 0;
- finished = true;
- }
- }
- }
- return true;
- }
-
- bool Animation2D::is_finished()const
- {
- return finished;
- }
-
- void Animation2D::set_transparency(unsigned alpha)
- {
- this->alpha = alpha;
- }
-
- void Animation2D::render_frame(unsigned seq, unsigned fr, int alpha)const
- {
- sequences->render_frame( seq, fr, alpha );
- }
-
- unsigned Animation2D::get_frame_count(unsigned seq)const
- {
- return sequences->get_frame_count( seq );
- }
- unsigned Animation2D::get_sequence_count()const
- {
- return sequences->get_sequence_count();
- }
- unsigned Animation2D::get_height()const
- {
- return sequences->get_height( current_seq, current_fr );
- }
- unsigned Animation2D::get_width()const
- {
- return sequences->get_width( current_seq, current_fr );
- }
- unsigned Animation2D::get_height(unsigned seq, unsigned fr)const
- {
- return sequences->get_height( seq, fr );
- }
- unsigned Animation2D::get_width(unsigned seq, unsigned fr )const
- {
- return sequences->get_width( seq, fr );
- }
-