MCPcopy Create free account
hub / github.com/OneLoneCoder/olcPixelGameEngine / Frame

Class Frame

utilities/olcUTIL_Animate2D.h:73–98  ·  view source on GitHub ↗

This class rerpresents a valid "frame" of an animation. It could be from any image source, and any location withing that image source. Once it's constructed, it's advised not to change it, as this likely indicates a usage bug. "Sourceless" frames are valid too - this is useful if you have a particular animation set, but want to apply it to a variety of sources, for example sprite maps with common

Source from the content-addressed store, hash-verified

71 // "Sourceless" frames are valid too - this is useful if you have a particular animation set, but
72 // want to apply it to a variety of sources, for example sprite maps with common layouts.
73 class Frame
74 {
75 public:
76 inline Frame(const olc::Renderable* gfxSource, const geom2d::rect<int32_t>& rectSource = { {0,0},{0,0} })
77 : gfxImageSource(gfxSource), rectFrameSource(rectSource)
78 {
79 // If no source rectangle specified then use whole image source. Ignore in the event
80 // that a frame is set up as source-less
81 if(gfxSource && rectFrameSource.size.x == 0)
82 rectFrameSource.size = gfxSource->Sprite()->Size();
83 }
84
85 inline const olc::Renderable* GetSourceImage() const
86 {
87 return gfxImageSource;
88 }
89
90 inline const geom2d::rect<int32_t>& GetSourceRect() const
91 {
92 return rectFrameSource;
93 }
94
95 private:
96 const olc::Renderable* gfxImageSource;
97 geom2d::rect<int32_t> rectFrameSource;
98 };
99
100 // Animation styles decide how the frames should be traversed in time
101 enum class Style : uint8_t

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected