1 #ifndef JUGIMAP_SPRITES_H
2 #define JUGIMAP_SPRITES_H
13 class JugiMapBinaryLoader;
21 struct AnimatedProperties;
26 struct SourceSpriteReplacements;
52 OVERLAY_COLOR = 1 << 7,
56 TEXT_STRING = 1 << 11,
65 TRANSFORMATION = POSITION | FLIP | SCALE | ROTATION | HANDLE,
66 APPEARANCE = ALPHA | BLEND | OVERLAY_COLOR | COLOR,
67 ALL = TRANSFORMATION | APPEARANCE | TEXTURE | TEXT_STRING | VISIBILITY | ID | TAG | DATA | LINK
232 void SetName(
const std::string& _nameID){ name = _nameID; }
358 float GetRotation(
bool _includeAnimatedProperties =
true);
436 float GetAlpha(
bool _includeAnimatedProperties =
true);
603 SourceSpriteReplacements* GetSourceSpriteReplacements(){
return ssr;}
605 SourceSprite* GetOriginalSourceSprite();
610 void SetBoundingBox(
const Rectf &_boundingBox) { boundingBox = _boundingBox;}
623 SpriteLayer *layer =
nullptr;
624 SourceSprite * sourceSprite=
nullptr;
625 ComposedSprite * parentComposedSprite =
nullptr;
631 CustomObject* customObject =
nullptr;
635 bool engineSpriteUsedDirectly =
false;
642 float rotation = 0.0;
652 bool colorOverlayActive =
false;
653 ColorRGBA colorOverlayRGBA = 0;
658 AnimatedProperties* ap =
nullptr;
662 std::vector<Parameter> parameters;
666 SourceSpriteReplacements* ssr =
nullptr;
667 SourceSpriteReplacements* ssrChildren =
nullptr;
697 virtual void SetVisible(
bool _visible)
override;
716 return Vec2f(cScale * _scale.
x, cScale * _scale.
y);
722 return (cFlip.
y + cFlip.
x == 1)? cRotation - _rotation : cRotation + _rotation;
728 return Vec2i((_flip.
x==1)? 1 - cFlip.
x : cFlip.
x , (_flip.
y==1)? 1 - cFlip.
y : cFlip.
y);
739 void SetChildrenSpritesChanged(
bool _childrenSpritesChanged);
745 Vec2i GetCFlip(){
return cFlip; }
746 float GetCScale(){
return cScale; }
747 float GetCRotation(){
return cRotation; }
757 std::vector<Layer*>layers;
763 float cRotation = 0.0;
770 bool childrenSpritesChanged =
false;
776 void UpdateTransform();
870 void SetColliderShapes();
871 void UpdateColliderAndBoundingBox();
876 Collider *collider =
nullptr;
877 bool preserveShapesOnNullActiveImage =
true;
972 void _SetFont(
Font *_font){ font = _font; }
982 void _SetRelativeHandle(
Vec2f _relHandle){ relHandle = _relHandle; }
990 std::string textString;
991 Font* font =
nullptr;
992 ColorRGBA color{255,255,255,255};
995 Vec2f relHandle{0.5, 0.5};
1000 void AdjustRelativeHandleToRoundedSize();
1032 #endif // JUGIMAP_SPRITES_H
void SetId(int _id)
Set the id of this sprite to the given _id.
Definition: jmSprites.h:219
void SetAlpha(float _alpha)
Set the alpha of this sprite to the given **_alpha**.
Definition: jmSprites.cpp:226
virtual void SetActiveImage(GraphicItem *_image)
Set the active image to the given *_image*.
Definition: jmSprites.cpp:602
virtual void UpdateBoundingBox() override
Update the map bounding box of this sprite.
Definition: jmSprites.cpp:1246
AffineMat3< float > AffineMat3f
AffineMat3 struct in float precision.
Definition: jmCommon.h:381
virtual void ResetAnimatedProperties() override
Set sprite properties to pre-animation state.
Definition: jmSprites.cpp:1274
int GetActiveImageFrameIndex()
Returns the index of the active image in the source sprite's graphic items vector.
Definition: jmSprites.cpp:615
The CustomObject class is the base class for custom objects.
Definition: jmCommon.h:555
void SetChangeFlags(int _changeFlags)
Set the change flags of this sprite to the given *_changeFlags*.
Definition: jmSprites.cpp:291
virtual void AppendAnimatedProperties(AnimatedProperties &_ap)
Set sprite properties from the given **_ap** object.
Definition: jmSprites.cpp:539
void SetActiveImageByFrameIndex(int _frameIndex)
Set the active image to the image at the given *_frameIndex* in the source sprite's graphic items vec...
Definition: jmSprites.cpp:630
void SetDisabledEngineSpriteUpdate(bool _engineSpriteUsedDirectly)
Set a boolean flag which indicates if this sprite's engine sprite is used directly.
Definition: jmSprites.h:162
float GetGlobalRotation(bool _includeAnimatedProperties=true)
Returns the global rotation of this sprite.
Definition: jmSprites.cpp:430
Not included in the physics simulation.
Definition: jmSprites.h:795
void _SetSize(Vec2f _size)
Set this text sprite to be clickable.
Definition: jmSprites.cpp:931
void _SetLayer(SpriteLayer *_spriteLayer)
Set the layer of this sprite to the given **_sourceSprite**.
Definition: jmSprites.h:599
virtual void CopyProperties(Sprite *_sprite, int copyFlags)
Copy properties from the given **_sprite**.
Definition: jmSprites.cpp:65
Included in the physics simulation as a static object.
Definition: jmSprites.h:796
void SetColorOverlayBlend(ColorOverlayBlend _colorOverlayBlend)
Set the color overlay blend of this sprite to the given **_colorOverlayBlend**.
Definition: jmSprites.cpp:278
Blend GetOwnBlend()
Returns the own blend of this sprite.
Definition: jmSprites.h:452
void SetRotation(float _rotation)
Set the rotation of this sprite to the given **_rotation**.
Definition: jmSprites.cpp:187
float GetAlpha(bool _includeAnimatedProperties=true)
Returns the alpha of this sprite.
Definition: jmSprites.cpp:477
Property
The Property enumerator provides flags for sprite properties.
Definition: jmSprites.h:41
void SetCollider(Collider *_collider)
Set collider to the given *_collider*.
Definition: jmSprites.h:842
void SetTextString(const std::string &_textString)
Set the text string of this text sprite to the given _textString.
Definition: jmSprites.cpp:882
SpriteKind
The kinds of sprite. Used as identifier for Sprite objects.
Definition: jmGlobal.h:30
Vec2f ConvertToWorldPos(const Vec2f &_pos)
Returns a position in the map system from the given *_pos* in the system of this composed sprite.
Definition: jmSprites.h:708
ColorRGBA GetColor()
Returns the color of this text sprite.
Definition: jmSprites.h:931
Vec2f GetHandle()
Returns the handle point of this sprite.
Definition: jmSprites.h:412
PhysicsMode
The physics mode of the standard sprite.
Definition: jmSprites.h:794
Color in RGBA color space - integer variant.
Definition: jmColor.h:15
Vec2f GetGlobalPosition(bool _includeAnimatedProperties=true)
Returns the global position of this sprite.
Definition: jmSprites.cpp:337
virtual void AppendAnimatedProperties(AnimatedProperties &_ap) override
Set sprite properties from the given **_ap** object.
Definition: jmSprites.cpp:750
Sprite * MakeActiveCopy()
Create a new sprite which is an active copy of this sprite.
Definition: jmSprites.cpp:56
virtual bool PointInside(Vec2f _pos)
Returns true if the given point **_pos** is inside the shape(s) of this sprite; otherwise returns fal...
Definition: jmSprites.h:543
int GetChangeFlags()
Returns the change flags of this sprite.
Definition: jmSprites.h:582
Vec2< int > Vec2i
Vec2 struct in integer precision.
Definition: jmCommon.h:166
virtual void CaptureForLerpDrawing() override
Capture the sprite properties, usually the position only, required for the lerp drawing.
Definition: jmSprites.cpp:1263
void _SetSourceSprite(SourceSprite *_sourceSprite)
Set the source sprite of this sprite to the given **_sourceSprite**.
Definition: jmSprites.h:592
virtual bool HasCollider() override
Returns true if this sprite has assigned a collider; otherwise returns false.
Definition: jmSprites.cpp:1165
std::string GetTextString()
Returns the string of this text sprite.
Definition: jmSprites.h:918
Included in the physics simulation as a kinematic object.
Definition: jmSprites.h:798
Vec2f GetPosition(bool _includeAnimatedProperties=true)
Returns the position of this sprite.
Definition: jmSprites.cpp:316
Font * GetFont()
Returns the font of this text sprite.
Definition: jmSprites.h:906
Sprite * MakePassiveCopy()
Create a new sprite which is a passive copy of this sprite.
Definition: jmSprites.cpp:38
Vec2f GetSize()
Returns the size of this text sprite.
Definition: jmSprites.cpp:919
The GraphicItem class defines the equivalent object from JugiMap Editor.
Definition: jmSourceGraphics.h:34
int GetId()
Returns the id of this sprite.
Definition: jmSprites.h:225
virtual ~StandardSprite()
Destructor.
Definition: jmSprites.cpp:566
virtual void InitEngineObjects() override
Initialize the engine sprite.
Definition: jmSprites.cpp:1091
void SetOwnBlend(Blend _blend)
Set the own blend of this sprite to the given **_blend**.
Definition: jmSprites.cpp:239
void AppendToChangeFlags(int _changeFlags)
Append the given *_changeFlags* to the change flags of this sprite with a biwise operation....
Definition: jmSprites.cpp:303
AnimatedProperties * GetAnimatedProperties()
Returns the pre-animation properties.
Definition: jmSprites.h:504
virtual bool Overlaps(Sprite *_sprite) override
Returns true if the shapes of this and the given **_sprite** overelaps; otherwise returns false.
Definition: jmSprites.cpp:711
CustomObject * GetCustomObject()
Returns the custom object of this sprite if exists; otherwise returns nullptr.
Definition: jmSprites.h:268
The StandardSprite class defines the sprite from JugiMap Editor.
Definition: jmSprites.h:787
virtual void DrawEngineSprite()
Draw the engine sprite.
Definition: jmSprites.h:129
ColorRGBA GetOverlayColorRGBA(bool _includeAnimatedProperties=true)
Returns the overlay color of this sprite.
Definition: jmSprites.cpp:500
ComposedSprite * GetParentComposedSprite()
Returns the parent composed sprite of this sprite.
Definition: jmSprites.h:205
T x
The x coordinate.
Definition: jmCommon.h:25
AffineMat3< T > Invert() const
Returns a matrix formed by inverting this matrix.
Definition: jmCommon.h:281
The Sprite is the base sprite class.
Definition: jmSprites.h:32
void SetColorOverlayActive(bool _colorOverlayActive)
Set to true to make the color overlay active; set to false to disable the color overlay.
Definition: jmSprites.cpp:252
std::string GetName()
Returns the name of this sprite.
Definition: jmSprites.h:238
virtual bool Overlaps(Sprite *_sprite)
Returns true if the shapes of this and the given **_sprite** overelaps; otherwise returns false.
Definition: jmSprites.h:550
virtual void CreateAnimatedPropertiesIfNone()
Store current properties for animation purposes.
Definition: jmSprites.cpp:519
virtual void CopyProperties(Sprite *_sprite, int copyFlags) override
Copy properties from the given **_sprite**.
Definition: jmSprites.cpp:956
Vec2i ConvertToWorldFlip(const Vec2i &_flip)
Returns a cumulative flip in the map system from the given *_flip* in the system of this composed spr...
Definition: jmSprites.h:726
void SetColor(ColorRGBA _color)
Set the color of this text sprite to the given _color.
Definition: jmSprites.cpp:890
SpriteKind GetKind()
Returns the kind of this sprite.
Definition: jmSprites.cpp:147
Vec2f GetScale(bool _includeAnimatedProperties=true)
Returns the horizontal and vertical scale factor of this sprite.
Definition: jmSprites.cpp:362
virtual bool PointInside(Vec2f _pos) override
Returns true if the given point **_pos** is inside the shape(s) of this sprite; otherwise returns fal...
Definition: jmSprites.cpp:699
virtual void SetVisible(bool _visible)
Set the visibility of this sprite.
Definition: jmSprites.cpp:133
std::vector< jugimap::Parameter > & GetParameters()
Returns a reference to the vector of stored parameters in this sprite.
Definition: jmSprites.h:277
virtual bool RaycastHit(Vec2f _rayStart, Vec2f _rayEnd, Vec2f &_hitPos)
Returns true if a ray (line segment) from **_rayStart** to **_rayEnd** 'hits' at the shape(s) of this...
Definition: jmSprites.h:558
void SetName(const std::string &_nameID)
Set the name of this sprite to the given _nameID.
Definition: jmSprites.h:232
float GetHeight()
Returns the height of this text sprite.
Definition: jmSprites.cpp:897
Vec2f GetRelativeHandle()
Returns the relative handle of this text sprite.
Definition: jmSprites.h:958
void SetFlip(Vec2i _flip)
Set the horizontal and vertical flip factor of this sprite to the given **_flip**.
Definition: jmSprites.cpp:200
virtual void UpdateEngineObjects() override
Update the engine sprite.
Definition: jmSprites.cpp:1108
virtual ~ComposedSprite() override
Destructor.
Definition: jmSprites.cpp:1081
T y
The y coordinate.
Definition: jmCommon.h:26
Vec2f GetGlobalScale(bool _includeAnimatedProperties=true)
Returns the global scale factor of this sprite.
Definition: jmSprites.cpp:392
SpriteLayer * GetLayer()
Returns a sprite layer where this sprite is stored.
Definition: jmSprites.h:195
Vec2i GetGlobalFlip(bool _includeAnimatedProperties=true)
Returns the horizontal and vertical world flip factor of this sprite.
Definition: jmSprites.cpp:462
virtual bool PointInside(Vec2f _pos) override
Returns true if the given point **_pos** is inside the shape(s) of this sprite; otherwise returns fal...
Definition: jmSprites.cpp:869
void SetTag(int _tag)
Set the tag of this sprite to the given _tag.
Definition: jmSprites.h:246
Rect< float > Rectf
Rect struct in float precision.
Definition: jmCommon.h:257
virtual bool RaycastHit(Vec2f _rayStart, Vec2f _rayEnd, Vec2f &_hitPos) override
Returns true if a ray (line segment) from **_rayStart** to **_rayEnd** 'hits' at the shape(s) of this...
Definition: jmSprites.cpp:738
GraphicItem * GetActiveImage()
Returns the active image.
Definition: jmSprites.h:814
Rectf GetBoundingBox()
Returns the world bounding rectangle of this sprite.
Definition: jmSprites.h:182
virtual bool PointInside(Vec2f _pos) override
Returns true if the given point **_pos** is inside the shape(s) of this sprite; otherwise returns fal...
Definition: jmSprites.cpp:1181
virtual void SetHandle(Vec2f _handle)
Set the handle point of this sprite to the given **_handle** point.
Definition: jmSprites.cpp:213
Vec2< float > Vec2f
Vec2 struct in float precision.
Definition: jmCommon.h:167
ColorOverlayBlend GetOverlayColorBlend(bool _includeAnimatedProperties=true)
Returns the overlay color blend of this sprite.
Definition: jmSprites.cpp:509
int GetTag()
Returns the tag of this sprite.
Definition: jmSprites.h:252
SkeletonSprite()
Constructor.
Definition: jmSprites.h:1017
The SkeletonSprite class defines the skeleton sprite from JugiMap Editor.
Definition: jmSprites.h:1011
void SetScale(Vec2f _scale)
Set the horizontal and vertical scale factor of this sprite to the given **_scale**.
Definition: jmSprites.cpp:174
virtual PhysicsMode GetPhysicsMode()
Returns the physics mode.
Definition: jmSprites.h:852
virtual void InitEngineObjects() override
Initialize the engine sprite.
Definition: jmSprites.cpp:788
TextSprite()
Constructor.
Definition: jmSprites.h:895
virtual void SetVisible(bool _visible) override
Set the visibility of this sprite.
Definition: jmSprites.cpp:1145
virtual void InitEngineObjects()
Initialize the engine sprite.
Definition: jmSprites.h:116
virtual void ResetAnimatedProperties()
Set sprite properties to pre-animation state.
Definition: jmSprites.cpp:529
virtual bool Overlaps(Sprite *_sprite) override
Returns true if the shapes of this and the given **_sprite** overelaps; otherwise returns false.
Definition: jmSprites.cpp:1201
virtual ~Sprite()
Destructor.
Definition: jmSprites.cpp:22
int GetDataFlags()
Returns the dataFlags of this sprite.
Definition: jmSprites.h:283
Included in the physics simulation as a dynamic object.
Definition: jmSprites.h:797
void SetPosition(Vec2f _position)
Set the position of this sprite to the given **_position**.
Definition: jmSprites.cpp:161
Vec2< T > Transform(const Vec2< T > &v) const
Returns a vector formed by multiplying the given vector v with this matrix.
Definition: jmCommon.h:306
bool IsVisible()
Returns true if this sprite is visible; otherwise returns false.
Definition: jmSprites.h:150
ComposedSprite()
Constructor.
Definition: jmSprites.h:691
StandardSprite()
Constructor.
Definition: jmSprites.h:803
virtual void UpdateEngineObjects()
Update the engine sprite.
Definition: jmSprites.h:122
virtual bool HasCollider()
Returns true if this sprite has assigned a collider; otherwise returns false.
Definition: jmSprites.h:536
The Font class defines fonts used in TextSprite objects.
Definition: jmFont.h:16
Matrix representation of the affine transformation.
Definition: jmCommon.h:263
float GetWidth()
Returns the width of this text sprite.
Definition: jmSprites.cpp:908
void UpdateBoundingBox() override
Update the map bounding box of this sprite.
Definition: jmSprites.cpp:575
Blend
The blend modes for the openGL pixel blending.
Definition: jmGlobal.h:101
bool IsOverlayColorActive()
Returns true if the overlay color of this sprite is active; otherwise returns false.
Definition: jmSprites.cpp:489
virtual void UpdateBoundingBox()
Update the map bounding box of this sprite.
Definition: jmSprites.h:176
bool IsEngineSpriteUsedDirectly()
Returns true if this sprite's engine sprite is used directly.
Definition: jmSprites.h:168
virtual void UpdateBoundingBox() override
Update the map bounding box of this sprite.
Definition: jmSprites.cpp:847
The ComposedSprite class defines the composed sprite from JugiMap Editor.
Definition: jmSprites.h:682
virtual bool RaycastHit(Vec2f _rayStart, Vec2f _rayEnd, Vec2f &_hitPos) override
Returns true if a ray (line segment) from **_rayStart** to **_rayEnd** 'hits' at the shape(s) of this...
Definition: jmSprites.cpp:1226
SourceSprite * GetSourceSprite()
Returns the source sprite of this sprite.
Definition: jmSprites.h:199
float GetRotation(bool _includeAnimatedProperties=true)
Returns the rotation of this sprite in degrees.
Definition: jmSprites.cpp:414
Collider * GetCollider()
Returns the collider or nullptr if none.
Definition: jmSprites.h:846
2d vector.
Definition: jmCommon.h:23
The SourceSprite class defines the source sprite from JugiMap Editor.
Definition: jmSourceGraphics.h:221
void SetColorOverlayRGBA(ColorRGBA _colorOverlayRGBA)
Set the color overlay of this sprite to the given **_colorOverlayRGBA**.
Definition: jmSprites.cpp:265
virtual void SetPhysicsMode(PhysicsMode _physicsMode)
Set the physics mode to the given *_physicsMode*.
Definition: jmSprites.h:858
std::vector< Layer * > & GetLayers()
Returns a reference to the vector of stored layers in this composed sprite.
Definition: jmSprites.h:736
virtual bool HasCollider() override
Returns true if this sprite has assigned a collider; otherwise returns false.
Definition: jmSprites.cpp:693
virtual void DrawEngineSprite() override
Draw the engine sprite.
Definition: jmSprites.cpp:1134
The TextSprite class defines the text sprite from JugiMap Editor.
Definition: jmSprites.h:889
Vec2i GetFlip(bool _includeAnimatedProperties=true)
Returns the horizontal and vertical flip factor of this sprite.
Definition: jmSprites.cpp:442
virtual void InitEngineObjects() override
Initialize the engine sprite.
Definition: jmSprites.cpp:1358
void SetCustomObject(CustomObject *_customObject)
Assign a custom object of this sprite to the given _customObject.
Definition: jmSprites.h:262
float ConvertToWorldRotation(float _rotation)
Returns a cumulative rotation in the map system from the given *_rotation* in the system of this comp...
Definition: jmSprites.h:720
virtual void CaptureForLerpDrawing()
Capture the sprite properties, usually the position only, required for the lerp drawing.
Definition: jmSprites.h:188
The JugiMapBinaryLoader class loads data from jugimap binary files (.jmb).
Definition: jmMapBinaryLoader.h:37
Sprite()
Constructor.
Definition: jmSprites.h:72
Vec2f ConvertToWorldScale(const Vec2f &_scale)
Returns a cumulative scale in the map system from the given *_scale* in the system of this composed s...
Definition: jmSprites.h:714
The SpriteLayer class defines the sprite and tile layers from JugiMap Editor.
Definition: jmLayers.h:303
ColorOverlayBlend
The blend modes for the shader based pixel blending which simulate photoshop blending modes.
Definition: jmGlobal.h:112
virtual bool IsEngineSpriteInitialized()
Returns true if the engine sprite of this sprite has been initialized; otherwise returns false.
Definition: jmSprites.h:135