GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
Direction.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #pragma once
7 
8 #include <vector>
9 #include "GDCore/String.h"
10 #include "GDCore/Extensions/Builtin/SpriteExtension/Sprite.h"
11 namespace gd {
12 class SerializerElement;
13 }
14 
15 namespace gd {
16 
28 class GD_CORE_API Direction {
29  public:
30  Direction();
31  virtual ~Direction();
32 
36  inline bool IsLooping() const { return loop; }
37 
41  void SetLoop(bool loop_);
42 
46  inline double GetTimeBetweenFrames() const { return timeBetweenFrame; }
47 
53  void SetTimeBetweenFrames(double time);
54 
63  const Sprite& GetSprite(std::size_t nb) const;
64 
73  Sprite& GetSprite(std::size_t nb);
74 
80  const std::vector<gd::String>& GetSpriteNames() const;
81 
87  bool HasNoSprites() const;
88 
94  std::size_t GetSpritesCount() const;
95 
101  void RemoveSprite(std::size_t index);
102 
106  void RemoveAllSprites();
107 
111  void AddSprite(const Sprite& sprite);
112 
116  void SwapSprites(std::size_t firstSpriteIndex, std::size_t secondSpriteIndex);
117 
121  void MoveSprite(std::size_t oldIndex, std::size_t newIndex);
122 
127  virtual void SetMetadata(const gd::String& metadata_) { metadata = metadata_; }
128 
132  virtual const gd::String& GetMetadata() const { return metadata; }
133 
134  void UnserializeFrom(const gd::SerializerElement& element);
135  void SerializeTo(gd::SerializerElement& element) const;
136 
137  private:
138  bool loop;
139  double timeBetweenFrame;
140  std::vector<Sprite> sprites;
141  gd::String metadata;
142 };
143 
144 } // namespace gd
Class defining a direction (set of frames) of an Animation.
Definition: Direction.h:28
virtual const gd::String & GetMetadata() const
Return the (optional) metadata associated to the Direction.
Definition: Direction.h:132
bool IsLooping() const
Return true if sprites looping is activated.
Definition: Direction.h:36
virtual void SetMetadata(const gd::String &metadata_)
Set the metadata (any string) associated to the Direction.
Definition: Direction.h:127
double GetTimeBetweenFrames() const
Get the time between each sprite.
Definition: Direction.h:46
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
Represents a sprite to be displayed on the screen.
Definition: Sprite.h:25
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24