1 #include "animationfactory.h"
4 #include "namedsprite.h"
5 #include "pointconverter.h"
6 #include "graphicalapi.h"
8 AnimationFactory::AnimationFactory(GraphicalAPI
* api
)
10 m_group
= AnimationGroupPtr(new AnimationGroup
);
13 AnimationGroupPtr
AnimationFactory::group() const {
17 void AnimationFactory::addPreAnimation(const Animate::Scheme
& scheme
, Animate::AnimationType type
) {
18 m_group
->addPreAnimation(m_api
->animate(scheme
, type
));
21 void AnimationFactory::addPostAnimation(const Animate::Scheme
& scheme
, Animate::AnimationType type
) {
22 m_group
->addPostAnimation(m_api
->animate(scheme
, type
));
25 AnimationFactory::operator AnimationGroupPtr() const {
33 move::move(const NamedSprite
& sprite
, const Point
& to
)
37 AnimationPtr
move::run(const PointConverter
* converter
, AnimationType type
) const {
40 return AnimationPtr(new MovementAnimation(m_sprite
.sprite(), converter
->toReal(m_to
)));
43 return AnimationPtr(new InstantAnimation(m_sprite
.sprite(), converter
->toReal(m_to
)));
47 appear::appear(const NamedSprite
& sprite
)
48 : m_sprite(sprite
) { }
50 AnimationPtr
appear::run(const PointConverter
*, AnimationType type
) const {
53 return AnimationPtr(new FadeAnimation(m_sprite
.sprite(), 0, 255));
56 return AnimationPtr(new DropAnimation(m_sprite
.sprite()));
60 disappear::disappear(const NamedSprite
& sprite
)
61 : m_sprite(sprite
) { }
63 AnimationPtr
disappear::run(const PointConverter
*, AnimationType type
) const {
66 return AnimationPtr(new FadeAnimation(m_sprite
.sprite(), 255, 0));
69 return AnimationPtr(new CaptureAnimation(m_sprite
.sprite()));
73 destroy::destroy(const NamedSprite
& sprite
)
74 : m_sprite(sprite
) { }
76 AnimationPtr
destroy::run(const PointConverter
*, AnimationType type
) const {
79 return AnimationPtr(new ExplodeAnimation(m_sprite
.sprite(), Random::instance()));
82 return AnimationPtr(new CaptureAnimation(m_sprite
.sprite()));
86 morph::morph(const NamedSprite
& sprite
, const NamedSprite
& new_sprite
)
88 , m_new_sprite(new_sprite
) { }
90 AnimationPtr
morph::run(const PointConverter
*, AnimationType type
) const {
93 return AnimationPtr(new CrossFadingAnimation(m_sprite
.sprite(), m_new_sprite
.sprite()));
96 return AnimationPtr(new PromotionAnimation(m_sprite
.sprite(), m_new_sprite
.sprite()));