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,
51  gd::Project& project,
52  gd::Layout& scene) override;
53  bool UpdateInitialInstanceProperty(gd::InitialInstance& position,
54  const gd::String& name,
55  const gd::String& value,
56  gd::Project& project,
57  gd::Layout& scene) override;
58 
62  const SpriteAnimationList& GetAnimations() const;
63 
67  SpriteAnimationList& GetAnimations();
68 
73  void SetUpdateIfNotVisible(bool updateIfNotVisible_) {
74  updateIfNotVisible = updateIfNotVisible_;
75  }
76 
81  bool GetUpdateIfNotVisible() const { return updateIfNotVisible; }
82 
83  private:
84  void DoUnserializeFrom(gd::Project& project,
85  const gd::SerializerElement& element) override;
86  void DoSerializeTo(gd::SerializerElement& element) const override;
87 
88  SpriteAnimationList animations;
89 
90  bool updateIfNotVisible;
93 };
94 
95 } // 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:25
Represent a layout ( also called a scene ) of a project.
Definition: Layout.h:39
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:50
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:81
std::unique_ptr< gd::ObjectConfiguration > Clone() const override
Definition: SpriteObject.h:40
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:73
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24