Rose
Sprite.h
Go to the documentation of this file.
1 
13 #pragma once
14 
15 #include "Widget.h"
16 #include "Types.h"
17 #include "ImageRepository.h"
18 
19 namespace rose {
27  class Sprite : public Widget {
28  public:
29  Sprite() = default;
30  ~Sprite() override = default;
31  Sprite(Sprite &&) = delete;
32  Sprite(const Sprite &) = delete;
33  Sprite& operator=(Sprite &&) = delete;
34  Sprite& operator=(const Sprite &) = delete;
35 
41  Sprite(Rose &rose, Widget *parent);
42 
49  Sprite(std::shared_ptr<Widget> parent, ImageId imageId) : Sprite(parent) {
50  mImageId = imageId;
51  }
52 
57  void draw(sdl::Renderer &renderer, RectangleInt parentRect) override;
58 
64  void setVector(Size<float> vector, uint32_t time) {
65  mCurrentVector = vector;
66  mVectorTicks = (float) time;
67  }
68 
73  void setImageId(ImageId imageId) { mImageId = imageId; }
74 
75  protected:
76  ImageId mImageId{ImageRepository::InvalidImageId};
77 
78  PositionInt mTextureFrame{};
79  PositionInt mTextureOffset{};
80 
81  uint32_t mTicks;
82 
83  Position<float> mCurrentPosition;
84  Size<float> mCurrentVector;
85  float mVectorTicks{};
86  int mFrameTicks{};
87  int mFrameRate{};
88  };
89 }
The Sprite Class.
Sprite(std::shared_ptr< Widget > parent, ImageId imageId)
Constructor.
Definition: Sprite.h:49
void setImageId(ImageId imageId)
Set the ImageRepository::ImageId of the texture to use as the sprite.
Definition: Sprite.h:73
void setVector(Size< float > vector, uint32_t time)
Give the sprite a vector to travel and a time in milliseconds that it should take to travers...
Definition: Sprite.h:64
void draw(sdl::Renderer &renderer, RectangleInt parentRect) override
Draw the sprite.
Definition: Sprite.cpp:16
static constexpr ImageId InvalidImageId
An invalid image ID which may be used for initialization.
Definition: ImageRepository.h:48
A sprite is a free roaming texture that is directed using Signals and Slots.
Definition: Sprite.h:27
An element of the application user interface.
Definition: Visual.h:451
Written as a workaround for an issue in the SDL2 Library.
Definition: Renderer.h:64
ToDo: There is an issue that the initial scroll interaction is lost if the click/press lands on a Wid...
Definition: CelestialOverlay.cpp:13