GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
SpriteAnimationList.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 
7 #pragma once
8 
9 #include "GDCore/Extensions/Builtin/SpriteExtension/Animation.h"
10 
11 namespace gd {
12 class InitialInstance;
13 class SerializerElement;
14 class PropertyDescriptor;
15 class ArbitraryResourceWorker;
16 } // namespace gd
17 
18 namespace gd {
19 
30 class GD_CORE_API SpriteAnimationList {
31  public:
33  virtual ~SpriteAnimationList();
34 
35  void ExposeResources(gd::ArbitraryResourceWorker& worker);
36 
41  const Animation& GetAnimation(std::size_t nb) const;
42 
47  Animation& GetAnimation(std::size_t nb);
48 
52  std::size_t GetAnimationsCount() const { return animations.size(); };
53 
57  bool HasAnimationNamed(const gd::String &name) const;
58 
62  void AddAnimation(const Animation& animation);
63 
67  bool RemoveAnimation(std::size_t nb);
68 
72  void RemoveAllAnimations() { animations.clear(); }
73 
77  bool HasNoAnimations() const { return animations.empty(); }
78 
82  void SwapAnimations(std::size_t firstIndex, std::size_t secondIndex);
83 
87  void MoveAnimation(std::size_t oldIndex, std::size_t newIndex);
88 
93  const std::vector<Animation>& GetAllAnimations() const { return animations; }
94 
99  return adaptCollisionMaskAutomatically;
100  }
101 
106  adaptCollisionMaskAutomatically = enable;
107  }
108 
109  void UnserializeFrom(const gd::SerializerElement& element);
110  void SerializeTo(gd::SerializerElement& element) const;
111 
112  private:
113 
114  mutable std::vector<Animation> animations;
115 
116  static Animation badAnimation; //< Bad animation when an out of bound
117  // animation is requested.
118  bool adaptCollisionMaskAutomatically;
122 };
123 
124 } // namespace gd
Class representing an animation of a SpriteObject.
Definition: Animation.h:22
ArbitraryResourceWorker is used so as to inventory resources and sometimes update them.
Definition: ArbitraryResourceWorker.h:44
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
A list of animations, containing directions with images and collision mask.
Definition: SpriteAnimationList.h:30
std::size_t GetAnimationsCount() const
Return the number of animations this object has.
Definition: SpriteAnimationList.h:52
void RemoveAllAnimations()
Remove all animations.
Definition: SpriteAnimationList.h:72
bool AdaptCollisionMaskAutomatically() const
Check if the collision mask adapts automatically to the animation.
Definition: SpriteAnimationList.h:98
const std::vector< Animation > & GetAllAnimations() const
Return a read-only reference to the vector containing all the animation of the object.
Definition: SpriteAnimationList.h:93
bool HasNoAnimations() const
Return true if the object hasn't any animation.
Definition: SpriteAnimationList.h:77
void SetAdaptCollisionMaskAutomatically(bool enable)
Set if the collision mask adapts automatically to the animation.
Definition: SpriteAnimationList.h:105
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24