Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Segue.h
1 /*
2  * Gamedev Framework (gf)
3  * Copyright (C) 2016-2019 Julien Bernard
4  *
5  * This software is provided 'as-is', without any express or implied
6  * warranty. In no event will the authors be held liable for any damages
7  * arising from the use of this software.
8  *
9  * Permission is granted to anyone to use this software for any purpose,
10  * including commercial applications, and to alter it and redistribute it
11  * freely, subject to the following restrictions:
12  *
13  * 1. The origin of this software must not be misrepresented; you must not
14  * claim that you wrote the original software. If you use this software
15  * in a product, an acknowledgment in the product documentation would be
16  * appreciated but is not required.
17  * 2. Altered source versions must be plainly marked as such, and must not be
18  * misrepresented as being the original software.
19  * 3. This notice may not be removed or altered from any source distribution.
20  */
21 #ifndef GF_SEGUE_H
22 #define GF_SEGUE_H
23 
24 #include "Drawable.h"
25 #include "Easings.h"
26 #include "Portability.h"
27 #include "Rect.h"
28 #include "Time.h"
29 #include "Vertex.h"
30 
31 namespace gf {
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 inline namespace v1 {
34 #endif
35 
36  class SegueEffect;
37  class Texture;
38 
45  class GF_API Segue : public Drawable {
46  public:
50  Segue();
51 
57  void start(Time time);
58 
62  void stop();
63 
69  void update(Time time);
70 
76  bool isActive() {
77  return m_currentTime < m_totalTime;
78  }
79 
86  void setTextures(const Texture& texture0, const Texture& texture1);
87 
93  void setEffect(SegueEffect& effect) {
94  m_effect = &effect;
95  }
96 
102  void setEasing(Easing easing) {
103  m_easing = easing;
104  }
105 
106  virtual void draw(RenderTarget& target, const RenderStates& states) override;
107 
108  private:
109  void updatePositions();
110  void updateTexCoords();
111 
112  private:
113  const Texture *m_texture0;
114  const Texture *m_texture1;
115  RectF m_textureRect;
116  SegueEffect *m_effect;
117  Easing m_easing;
118  Vertex m_vertices[4];
119 
120  Time m_totalTime;
121  Time m_currentTime;
122  };
123 
124 #ifndef DOXYGEN_SHOULD_SKIP_THIS
125 }
126 #endif
127 }
128 
129 #endif // GF_SEGUE_H
Base class for all render targets (window, texture, ...)
Definition: RenderTarget.h:90
Define the states used for drawing to a RenderTarget.
Definition: RenderStates.h:82
A point associated with a color and a texture coordinate.
Definition: Vertex.h:75
bool isActive()
Tell if the segue is still active.
Definition: Segue.h:76
Abstract base class for objects that can be drawn to a render window.
Definition: Drawable.h:57
A segue effect.
Definition: SegueEffect.h:38
Represents a time value.
Definition: Time.h:65
A texture for colored images.
Definition: Texture.h:309
The namespace for gf classes.
Definition: Action.h:35
float(*)(float) Easing
An easing function.
Definition: Easings.h:48
A transition between two scenes.
Definition: Segue.h:45
void setEasing(Easing easing)
Set the easing for the segue.
Definition: Segue.h:102
void setEffect(SegueEffect &effect)
Set the effect to apply.
Definition: Segue.h:93