indexing description: "A manager that play's animations" date: "$Date$" revision: "$Revision$" class EM3D_ANIMATION_MANAGER inherit EM_TIME_SINGLETON create make feature {NONE} -- Initialization make( a_scene_manager: like scene_manager ) is -- Create a new animation manager do scene_manager := a_scene_manager create {DS_BILINKED_LIST[ EM_PAIR[ INTEGER, EM3D_ANIMATION_SET ] ]}animations.make fps := 25 end feature {NONE} -- status scene_manager: EM3D_SCENE_MANAGER -- The first parameter is the start time (negative means played only once animations: DS_LIST[ EM_PAIR[ INTEGER, EM3D_ANIMATION_SET ] ] feature play_next is -- Play the animation, to the next frame local cur_time: INTEGER position, dt: DOUBLE c: DS_LIST_CURSOR[ EM_PAIR[ INTEGER, EM3D_ANIMATION_SET ] ] do cur_time := time.ticks c := animations.new_cursor from c.start until c.after loop if c.item.first>0 then position := fps / 1000 * (cur_time + c.item.first) dt := c.item.second.end_time-c.item.second.start_time position := c.item.second.start_time + position - (position / dt ).truncated_to_integer * dt else position := c.item.second.start_time + fps / 1000 * (cur_time + c.item.first) end c.item.second.animate( position ) if c.item.first<0 and position > c.item.second.end_time then c.remove else c.forth end end end feature -- Commands play( an_animation: EM3D_ANIMATION_SET ) is -- Start playing an animation do stop( an_animation ) animations.force_last( create {EM_PAIR[ INTEGER, EM3D_ANIMATION_SET ]}.make( time.ticks, an_animation ) ) end play_once( an_animation: EM3D_ANIMATION_SET ) is -- Start playing an animation, only once do stop( an_animation ) animations.force_last( create {EM_PAIR[ INTEGER, EM3D_ANIMATION_SET ]}.make( -time.ticks, an_animation ) ) end stop( an_animation: EM3D_ANIMATION_SET ) is -- Stop an animation local c:DS_LIST_CURSOR[ EM_PAIR[ INTEGER, EM3D_ANIMATION_SET ] ] do c := animations.new_cursor from c.start until c.after loop if c.item.second = an_animation then c.remove else c.forth end end end feature -- Status fps: DOUBLE set_fps( a_value : like fps ) is -- Specify the Frames Per Second do fps := a_value end end