GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
SpriteObject.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/SpriteAnimationList.h"
10 #include "GDCore/Project/Object.h"
11 
12 namespace gd {
13 class InitialInstance;
14 class Object;
15 class Layout;
16 class SerializerElement;
17 class PropertyDescriptor;
18 } // namespace gd
19 
20 namespace gd {
21 
36 class GD_CORE_API SpriteObject : public gd::ObjectConfiguration {
37  public:
38  SpriteObject();
39  virtual ~SpriteObject();
40  std::unique_ptr<gd::ObjectConfiguration> Clone() const override {
41  return gd::make_unique<SpriteObject>(*this);
42  }
43 
44  void ExposeResources(gd::ArbitraryResourceWorker& worker) override;
45 
46  std::map<gd::String, gd::PropertyDescriptor> GetProperties() const override;
47  bool UpdateProperty(const gd::String& name, const gd::String& value) override;
48 
49  std::map<gd::String, gd::PropertyDescriptor> GetInitialInstanceProperties(
50  const gd::InitialInstance& position) override;
51  bool UpdateInitialInstanceProperty(gd::InitialInstance& position,
52  const gd::String& name,
53  const gd::String& value) override;
54 
55  size_t GetAnimationsCount() const override;
56 
57  const gd::String &GetAnimationName(size_t index) const override;
58 
59  bool HasAnimationNamed(const gd::String &animationName) const override;
60 
64  const SpriteAnimationList& GetAnimations() const;
65 
69  SpriteAnimationList& GetAnimations();
70 
75  void SetUpdateIfNotVisible(bool updateIfNotVisible_) {
76  updateIfNotVisible = updateIfNotVisible_;
77  }
78 
83  bool GetUpdateIfNotVisible() const { return updateIfNotVisible; }
84 
88  double GetPreScale() { return preScale; }
89 
95  void SetPreScale(double preScale_) {
96  if (preScale_ <= 0) {
97  return;
98  }
99  preScale = preScale_;
100  }
101 
102  private:
103  void DoUnserializeFrom(gd::Project& project,
104  const gd::SerializerElement& element) override;
105  void DoSerializeTo(gd::SerializerElement& element) const override;
106 
107  SpriteAnimationList animations;
108 
109  bool updateIfNotVisible;
112  double preScale;
113 };
114 
115 } // namespace gd
ArbitraryResourceWorker is used so as to inventory resources and sometimes update them.
Definition: ArbitraryResourceWorker.h:44
Represents an instance of an object to be created on a layout start up.
Definition: InitialInstance.h:26
Base class used to represent an object configuration. For example, this can be the animations in a sp...
Definition: ObjectConfiguration.h:38
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:51
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
Standard sprite object for extensions that implements the standard SpriteExtension (see gd::BuiltinEx...
Definition: SpriteObject.h:36
bool GetUpdateIfNotVisible() const
Check if the object animation should be played even if the object is hidden or far from the camera (f...
Definition: SpriteObject.h:83
std::unique_ptr< gd::ObjectConfiguration > Clone() const override
Definition: SpriteObject.h:40
double GetPreScale()
Return the scale applied to object to evaluate the default dimensions.
Definition: SpriteObject.h:88
void SetPreScale(double preScale_)
Set the scale applied to object to evaluate the default dimensions.
Definition: SpriteObject.h:95
void SetUpdateIfNotVisible(bool updateIfNotVisible_)
Set if the object animation should be played even if the object is hidden or far from the camera.
Definition: SpriteObject.h:75
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24