JugiMap Framework
jmSprites.h
1 #ifndef JUGIMAP_SPRITES_H
2 #define JUGIMAP_SPRITES_H
3 
4 #include "jmCommon.h"
5 #include "jmColor.h"
6 #include "jmGlobal.h"
7 
8 
9 
10 namespace jugimap {
11 
12 
13 class JugiMapBinaryLoader;
14 class GraphicItem;
15 class Layer;
16 class SpriteLayer;
17 class SourceSprite;
18 class ComposedSprite;
19 class StandardSprite;
20 class Collider;
21 struct AnimatedProperties;
22 
23 //class TextLayer;
24 class Font;
25 
26 struct SourceSpriteReplacements;
27 
28 
29 
32 class Sprite
33 {
34 public:
35  friend class JugiMapBinaryLoader;
36  friend class ComposedSprite;
37  friend class SpriteLayer;
38  friend class ComposedSprite;
39 
41  enum Property
42  {
43  NONE = 0,
44  POSITION = 1 << 0,
45  FLIP = 1 << 1,
46  SCALE = 1 << 2,
47  ROTATION = 1 << 3,
48  HANDLE = 1 << 4,
49 
50  ALPHA = 1 << 5,
51  BLEND = 1 << 6,
52  OVERLAY_COLOR = 1 << 7,
53  COLOR = 1 << 8,
54 
55  TEXTURE = 1 << 10,
56  TEXT_STRING = 1 << 11,
57 
58  VISIBILITY = 1 << 13,
59 
60  ID = 1 << 15,
61  TAG = 1 << 16,
62  DATA = 1 << 17,
63  LINK = 1 << 18,
64 
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
68  };
69 
70 
72  Sprite(){}
73  Sprite(const Sprite &s) = delete;
74  Sprite& operator=(const Sprite &s) = delete;
75 
76 
89 
90 
96 
97 
98 
99 
105  virtual void CopyProperties(Sprite *_sprite, int copyFlags);
106 
107 
108  //------ MANAGE ENGINE OBJECTS
109 
110 
116  virtual void InitEngineObjects(){}
117 
118 
122  virtual void UpdateEngineObjects(){}
123 
124 
129  virtual void DrawEngineSprite(){}
130 
131 
135  virtual bool IsEngineSpriteInitialized() {return false;}
136 
137 
138  //------
139 
140 
144  virtual void SetVisible(bool _visible);
145 
146 
150  bool IsVisible(){ return visible; }
151 
152 
153  //------
154 
162  void SetDisabledEngineSpriteUpdate(bool _engineSpriteUsedDirectly){ engineSpriteUsedDirectly = _engineSpriteUsedDirectly; }
163 
164 
168  bool IsEngineSpriteUsedDirectly(){ return engineSpriteUsedDirectly; }
169 
170 
171 
176  virtual void UpdateBoundingBox() {boundingBox = Rectf(position, position);}
177 
178 
182  Rectf GetBoundingBox(){ return boundingBox;}
183 
184 
188  virtual void CaptureForLerpDrawing(){}
189 
190 
191  //---- LINK OBJECTS
192 
193 
195  SpriteLayer* GetLayer() {return layer;}
196 
197 
199  SourceSprite* GetSourceSprite() {return sourceSprite;}
200 
201 
205  ComposedSprite* GetParentComposedSprite() {return parentComposedSprite;}
206 
207 
212 
213 
214  //------
219  void SetId(int _id){ id = _id; }
220 
221 
225  int GetId(){ return id;}
226 
227 
232  void SetName(const std::string& _nameID){ name = _nameID; }
233 
234 
238  std::string GetName(){ return name;}
239 
240 
241 
246  void SetTag(int _tag){ tag = _tag; }
247 
248 
252  int GetTag(){ return tag;}
253 
254 
255  //------
256 
262  void SetCustomObject(CustomObject* _customObject){ customObject = _customObject; }
263 
264 
268  CustomObject* GetCustomObject(){ return customObject; }
269 
270 
271  //------
272 
273 
277  std::vector<jugimap::Parameter> &GetParameters(){return parameters;}
278 
279 
283  int GetDataFlags() {return dataFlags;}
284 
285 
286  // TRANSFORM PROPERTIES
287  //-------------------------------------------------------------------------------
288 
292  void SetPosition(Vec2f _position);
293 
294 
302  Vec2f GetPosition(bool _includeAnimatedProperties = true);
303 
304 
312  Vec2f GetGlobalPosition(bool _includeAnimatedProperties = true);
313 
314 
315  //------
316 
317 
321  void SetScale(Vec2f _scale);
322 
323 
330  Vec2f GetScale(bool _includeAnimatedProperties = true);
331 
332 
339  Vec2f GetGlobalScale(bool _includeAnimatedProperties = true);
340 
341 
342  //------
343 
344 
349  void SetRotation(float _rotation);
350 
351 
358  float GetRotation(bool _includeAnimatedProperties = true);
359 
360 
367  float GetGlobalRotation(bool _includeAnimatedProperties = true);
368 
369 
370  //------
371 
372 
376  void SetFlip(Vec2i _flip);
377 
378 
386  Vec2i GetFlip(bool _includeAnimatedProperties = true);
387 
388 
396  Vec2i GetGlobalFlip(bool _includeAnimatedProperties = true);
397 
398 
399  //------
400 
408  virtual void SetHandle(Vec2f _handle);
409 
410 
412  Vec2f GetHandle() {return handle;}
413 
414 
415  // APPEARANCE PROPERTIES
416  //-------------------------------------------------------------------------------
417 
422  void SetAlpha(float _alpha);
423 
424 
428  //float GetAlpha(){return alpha;}
429 
430 
436  float GetAlpha(bool _includeAnimatedProperties = true);
437 
438 
439  //------
440 
446  void SetOwnBlend(Blend _blend);
447 
448 
452  Blend GetOwnBlend(){return ownBlend;}
453 
454 
455  //------
456 
461  void SetColorOverlayActive(bool _colorOverlayActive);
462 
463 
467  bool IsOverlayColorActive();
468 
469 
470 
474  void SetColorOverlayRGBA(ColorRGBA _colorOverlayRGBA);
475 
476 
482  ColorRGBA GetOverlayColorRGBA(bool _includeAnimatedProperties = true);
483 
484 
489  void SetColorOverlayBlend(ColorOverlayBlend _colorOverlayBlend);
490 
491 
497  ColorOverlayBlend GetOverlayColorBlend(bool _includeAnimatedProperties = true);
498 
499 
500  //------ ANIMATED PROPERTIES
501 
502 
504  AnimatedProperties* GetAnimatedProperties(){ return ap; }
505 
506 
511  virtual void CreateAnimatedPropertiesIfNone();
512 
513 
518  virtual void ResetAnimatedProperties();
519 
520 
525  virtual void AppendAnimatedProperties(AnimatedProperties& _ap);
526 
527 
528 
529  //------ COLLIDER
530 
531 
536  virtual bool HasCollider() { return false; }
537 
538 
543  virtual bool PointInside(Vec2f _pos){ return false; }
544 
545 
550  virtual bool Overlaps(Sprite *_sprite){ return false; }
551 
552 
558  virtual bool RaycastHit(Vec2f _rayStart, Vec2f _rayEnd, Vec2f &_hitPos){ return false; }
559 
560 
561 
562  //-------- CHANGE FLAGS
563 
564 
569  void SetChangeFlags(int _changeFlags);
570 
571 
576  void AppendToChangeFlags(int _changeFlags);
577 
578 
582  int GetChangeFlags() {return changeFlags;}
583 
584 
585  //--------
586 
587 
592  void _SetSourceSprite(SourceSprite *_sourceSprite){ sourceSprite = _sourceSprite; }
593 
594 
599  void _SetLayer(SpriteLayer *_spriteLayer){ layer = _spriteLayer; }
600 
601 
602 
603  SourceSpriteReplacements* GetSourceSpriteReplacements(){ return ssr;}
604 
605  SourceSprite* GetOriginalSourceSprite();
606 
607 
608 protected:
609 
610  void SetBoundingBox(const Rectf &_boundingBox) { boundingBox = _boundingBox;}
611 
612 
619  virtual ~Sprite();
620 
621 
622 private:
623  SpriteLayer *layer = nullptr; // LINK pointer to a layer where the sprite is stored.
624  SourceSprite * sourceSprite= nullptr; // LINK pointer to the belonging SourceSprite.
625  ComposedSprite * parentComposedSprite = nullptr; // LINK pointer to parent composed sprite if sprite is child of a composed sprite.
626 
627  //---
628  int id = 0;
629  std::string name;
630  int tag = 0;
631  CustomObject* customObject = nullptr;
632 
633  //---
634  bool visible = true;
635  bool engineSpriteUsedDirectly = false;
636 
637 
638  //--- TRANSFORMATION PROPERTIES
639  Vec2f position;
640  //Vec2f animationFrameOffset;
641  Vec2f scale = Vec2f(1.0, 1.0);
642  float rotation = 0.0;
643  Vec2i flip;
644  Vec2f handle;
645 
646  Rectf boundingBox;
647 
648 
649  //--- APPEARANCE PROPERTIES
650  float alpha = 1.0; // in scale [0 - 1.0]
651  Blend ownBlend = Blend::NOT_DEFINED;
652  bool colorOverlayActive = false;
653  ColorRGBA colorOverlayRGBA = 0;
654  ColorOverlayBlend colorOverlayBlend = ColorOverlayBlend::NORMAL;
655 
656 
657  //---
658  AnimatedProperties* ap = nullptr;
659 
660 
661  //--- DATA
662  std::vector<Parameter> parameters;
663  int dataFlags = 0;
664 
665 
666  SourceSpriteReplacements* ssr = nullptr;
667  SourceSpriteReplacements* ssrChildren = nullptr;
668 
669  //----
670  int changeFlags = 0;
671 
672 };
673 
674 
675 //=======================================================================================
676 
677 
682 class ComposedSprite : public Sprite
683 {
684 public:
685  friend class JugiMapBinaryLoader;
686  friend class Sprite;
687  friend class StandardSprite;
688  friend class SkeletonSprite;
689 
692 
693 
694  virtual void InitEngineObjects() override;
695  virtual void UpdateEngineObjects() override;
696  virtual void DrawEngineSprite() override;
697  virtual void SetVisible(bool _visible) override;
698  virtual bool HasCollider() override;
699  virtual bool PointInside(Vec2f _pos) override;
700  virtual bool Overlaps(Sprite *_sprite) override;
701  virtual bool RaycastHit(Vec2f _rayStart, Vec2f _rayEnd, Vec2f &_hitPos) override;
702  virtual void UpdateBoundingBox() override;
703  virtual void CaptureForLerpDrawing() override;
704  virtual void ResetAnimatedProperties() override;
705 
706 
709  {
710  return cTransform.Transform(_pos);
711  }
712 
715  {
716  return Vec2f(cScale * _scale.x, cScale * _scale.y);
717  }
718 
720  float ConvertToWorldRotation(float _rotation)
721  {
722  return (cFlip.y + cFlip.x == 1)? cRotation - _rotation : cRotation + _rotation; // one (and only one) flip changes direction of rotation !
723  }
724 
727  {
728  return Vec2i((_flip.x==1)? 1 - cFlip.x : cFlip.x , (_flip.y==1)? 1 - cFlip.y : cFlip.y);
729  }
730 
731 
732  Vec2f GetLocalPositionFromInMapPosition(const Vec2f &_pos) { return cTransform.Invert().Transform(_pos); }
733 
734 
736  std::vector<Layer*> & GetLayers() {return layers; }
737 
738 
739  void SetChildrenSpritesChanged(bool _childrenSpritesChanged);
740 
741 
742 
743  //----
744  AffineMat3f GetCTransform(){ return cTransform; }
745  Vec2i GetCFlip(){ return cFlip; }
746  float GetCScale(){ return cScale; }
747  float GetCRotation(){ return cRotation; }
748 
749 
750 protected:
751 
753  virtual ~ComposedSprite() override;
754 
755 
756 private:
757  std::vector<Layer*>layers; // OWNED
758 
759  // cumulative tranform properties
760  AffineMat3f cTransform;
761  Vec2i cFlip;
762  float cScale = 1.0;
763  float cRotation = 0.0;
764 
765  // misc - for construction purposes
766  Vec2i tileSize;
767  Vec2i nTiles;
768  Vec2i size;
769 
770  bool childrenSpritesChanged = false;
771 
772 
773 
774 
775 
776  void UpdateTransform();
777  //static void CopyLayers(ComposedSprite *csSource, ComposedSprite *csDest, JugiMapBinaryLoader *loader=nullptr);
778  static void CopyLayers(ComposedSprite *csSource, ComposedSprite *csDest, int &zOrder);
779 };
780 
781 
782 //=======================================================================================
783 
784 
787 class StandardSprite : public Sprite
788 {
789 public:
790  friend class JugiMapBinaryLoader;
791 
792 
796  STATIC=1,
799  };
800 
801 
804 
805 
806  void UpdateBoundingBox() override;
807  virtual bool HasCollider() override;
808  virtual bool PointInside(Vec2f _pos) override;
809  virtual bool Overlaps(Sprite *_sprite) override;
810  virtual bool RaycastHit(Vec2f _rayStart, Vec2f _rayEnd, Vec2f &_hitPos) override;
811 
812 
814  GraphicItem * GetActiveImage() {return activeImage;}
815 
816 
821  virtual void SetActiveImage(GraphicItem *_image);
822 
823 
828 
829 
833  void SetActiveImageByFrameIndex(int _frameIndex);
834 
835 
836  // bool GetPreserveShapesOnNullActiveImage(){ return preserveShapesOnNullActiveImage;}
837 
838 
842  void SetCollider(Collider *_collider){ collider = _collider; }
843 
844 
846  Collider * GetCollider(){ return collider; }
847 
848 
852  virtual PhysicsMode GetPhysicsMode(){ return physicsMode; }
853 
854 
858  virtual void SetPhysicsMode(PhysicsMode _physicsMode){ physicsMode = _physicsMode;}
859 
860 
861  virtual void AppendAnimatedProperties(AnimatedProperties& _ap) override;
862 
863 
864 
865 protected:
866 
868  virtual ~StandardSprite();
869 
870  void SetColliderShapes();
871  void UpdateColliderAndBoundingBox();
872 
873 
874 private:
875  GraphicItem *activeImage = nullptr; // LINK to currently active (displayed) image from the source sprite 'graphicItems' list.
876  Collider *collider = nullptr;
877  bool preserveShapesOnNullActiveImage = true;
878  PhysicsMode physicsMode = PhysicsMode::NO_PHYSICS;
879 
880 
881 
882 
883 };
884 
885 
886 
889 class TextSprite : public Sprite
890 {
891 public:
892 
893 
896 
897 
898  virtual void InitEngineObjects() override;
899  virtual void CopyProperties(Sprite *_sprite, int copyFlags) override;
900  virtual void UpdateBoundingBox() override;
901  virtual bool PointInside(Vec2f _pos) override;
902 
903  //------
904 
906  Font* GetFont(){ return font; }
907 
908 
912  void SetTextString(const std::string &_textString);
913 
914 
918  std::string GetTextString(){ return textString; }
919 
920 
925  void SetColor(ColorRGBA _color);
926 
927 
931  ColorRGBA GetColor(){ return color; }
932 
933 
938  float GetHeight();
939 
940 
945  float GetWidth();
946 
947 
952  Vec2f GetSize();
953 
954 
958  Vec2f GetRelativeHandle(){ return relHandle; }
959 
960 
964  //void SetClickable(bool _clickable) { clickable = _clickable; }
965 
966  //bool IsClickable(){ return clickable; }
967 
968  //virtual void ObtainSize() {}
969 
970 
971  void _SetSize(Vec2f _size);
972  void _SetFont(Font *_font){ font = _font; }
973  /*
981  */
982  void _SetRelativeHandle(Vec2f _relHandle){ relHandle = _relHandle; }
983 
984 
985 
986 protected:
987 
988 
989 private:
990  std::string textString;
991  Font* font = nullptr; // LINK pointer
992  ColorRGBA color{255,255,255,255};
993  Vec2f size;
994 
995  Vec2f relHandle{0.5, 0.5};
996 
997  //bool clickable = false;
998 
999 
1000  void AdjustRelativeHandleToRoundedSize();
1001 
1002 };
1003 
1004 
1005 
1006 
1007 //=======================================================================================
1008 
1011 class SkeletonSprite : public Sprite
1012 {
1013 public:
1014  friend class JugiMapBinaryLoader;
1015 
1018 
1019  virtual ~SkeletonSprite() override {}
1020 
1021  virtual void InitEngineObjects() override;
1022 
1023 };
1024 
1025 
1026 
1027 }
1028 
1029 
1030 
1031 
1032 #endif // JUGIMAP_SPRITES_H
jugimap::Sprite::SetId
void SetId(int _id)
Set the id of this sprite to the given _id.
Definition: jmSprites.h:219
jugimap::Sprite::SetAlpha
void SetAlpha(float _alpha)
Set the alpha of this sprite to the given **_alpha**.
Definition: jmSprites.cpp:226
jugimap::StandardSprite::SetActiveImage
virtual void SetActiveImage(GraphicItem *_image)
Set the active image to the given *_image*.
Definition: jmSprites.cpp:602
jugimap::ComposedSprite::UpdateBoundingBox
virtual void UpdateBoundingBox() override
Update the map bounding box of this sprite.
Definition: jmSprites.cpp:1246
jugimap::AffineMat3f
AffineMat3< float > AffineMat3f
AffineMat3 struct in float precision.
Definition: jmCommon.h:381
jugimap::ComposedSprite::ResetAnimatedProperties
virtual void ResetAnimatedProperties() override
Set sprite properties to pre-animation state.
Definition: jmSprites.cpp:1274
jugimap::StandardSprite::GetActiveImageFrameIndex
int GetActiveImageFrameIndex()
Returns the index of the active image in the source sprite's graphic items vector.
Definition: jmSprites.cpp:615
jugimap::CustomObject
The CustomObject class is the base class for custom objects.
Definition: jmCommon.h:555
jugimap::Sprite::SetChangeFlags
void SetChangeFlags(int _changeFlags)
Set the change flags of this sprite to the given *_changeFlags*.
Definition: jmSprites.cpp:291
jugimap::Sprite::AppendAnimatedProperties
virtual void AppendAnimatedProperties(AnimatedProperties &_ap)
Set sprite properties from the given **_ap** object.
Definition: jmSprites.cpp:539
jugimap::StandardSprite::SetActiveImageByFrameIndex
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
jugimap::Sprite::SetDisabledEngineSpriteUpdate
void SetDisabledEngineSpriteUpdate(bool _engineSpriteUsedDirectly)
Set a boolean flag which indicates if this sprite's engine sprite is used directly.
Definition: jmSprites.h:162
jugimap::Sprite::GetGlobalRotation
float GetGlobalRotation(bool _includeAnimatedProperties=true)
Returns the global rotation of this sprite.
Definition: jmSprites.cpp:430
jugimap::StandardSprite::NO_PHYSICS
Not included in the physics simulation.
Definition: jmSprites.h:795
jugimap::TextSprite::_SetSize
void _SetSize(Vec2f _size)
Set this text sprite to be clickable.
Definition: jmSprites.cpp:931
jugimap::Sprite::_SetLayer
void _SetLayer(SpriteLayer *_spriteLayer)
Set the layer of this sprite to the given **_sourceSprite**.
Definition: jmSprites.h:599
jugimap::Sprite::CopyProperties
virtual void CopyProperties(Sprite *_sprite, int copyFlags)
Copy properties from the given **_sprite**.
Definition: jmSprites.cpp:65
jugimap::StandardSprite::STATIC
Included in the physics simulation as a static object.
Definition: jmSprites.h:796
jugimap::Rect< float >
jugimap::Sprite::SetColorOverlayBlend
void SetColorOverlayBlend(ColorOverlayBlend _colorOverlayBlend)
Set the color overlay blend of this sprite to the given **_colorOverlayBlend**.
Definition: jmSprites.cpp:278
jugimap::Sprite::GetOwnBlend
Blend GetOwnBlend()
Returns the own blend of this sprite.
Definition: jmSprites.h:452
jugimap::Sprite::SetRotation
void SetRotation(float _rotation)
Set the rotation of this sprite to the given **_rotation**.
Definition: jmSprites.cpp:187
jugimap::Sprite::GetAlpha
float GetAlpha(bool _includeAnimatedProperties=true)
Returns the alpha of this sprite.
Definition: jmSprites.cpp:477
jugimap::Sprite::Property
Property
The Property enumerator provides flags for sprite properties.
Definition: jmSprites.h:41
jugimap::StandardSprite::SetCollider
void SetCollider(Collider *_collider)
Set collider to the given *_collider*.
Definition: jmSprites.h:842
jugimap::TextSprite::SetTextString
void SetTextString(const std::string &_textString)
Set the text string of this text sprite to the given _textString.
Definition: jmSprites.cpp:882
jugimap::SpriteKind
SpriteKind
The kinds of sprite. Used as identifier for Sprite objects.
Definition: jmGlobal.h:30
jugimap::ComposedSprite::ConvertToWorldPos
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
jugimap::TextSprite::GetColor
ColorRGBA GetColor()
Returns the color of this text sprite.
Definition: jmSprites.h:931
jugimap::Sprite::GetHandle
Vec2f GetHandle()
Returns the handle point of this sprite.
Definition: jmSprites.h:412
jugimap::StandardSprite::PhysicsMode
PhysicsMode
The physics mode of the standard sprite.
Definition: jmSprites.h:794
jugimap::ColorRGBA
Color in RGBA color space - integer variant.
Definition: jmColor.h:15
jugimap::Sprite::GetGlobalPosition
Vec2f GetGlobalPosition(bool _includeAnimatedProperties=true)
Returns the global position of this sprite.
Definition: jmSprites.cpp:337
jugimap::StandardSprite::AppendAnimatedProperties
virtual void AppendAnimatedProperties(AnimatedProperties &_ap) override
Set sprite properties from the given **_ap** object.
Definition: jmSprites.cpp:750
jugimap::Sprite::MakeActiveCopy
Sprite * MakeActiveCopy()
Create a new sprite which is an active copy of this sprite.
Definition: jmSprites.cpp:56
jugimap::Sprite::PointInside
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
jugimap::Sprite::GetChangeFlags
int GetChangeFlags()
Returns the change flags of this sprite.
Definition: jmSprites.h:582
jugimap::Vec2i
Vec2< int > Vec2i
Vec2 struct in integer precision.
Definition: jmCommon.h:166
jugimap::ComposedSprite::CaptureForLerpDrawing
virtual void CaptureForLerpDrawing() override
Capture the sprite properties, usually the position only, required for the lerp drawing.
Definition: jmSprites.cpp:1263
jugimap::Sprite::_SetSourceSprite
void _SetSourceSprite(SourceSprite *_sourceSprite)
Set the source sprite of this sprite to the given **_sourceSprite**.
Definition: jmSprites.h:592
jugimap::ColorOverlayBlend::NORMAL
Normal mode.
jugimap::ComposedSprite::HasCollider
virtual bool HasCollider() override
Returns true if this sprite has assigned a collider; otherwise returns false.
Definition: jmSprites.cpp:1165
jugimap::TextSprite::GetTextString
std::string GetTextString()
Returns the string of this text sprite.
Definition: jmSprites.h:918
jugimap::StandardSprite::KINEMATIC
Included in the physics simulation as a kinematic object.
Definition: jmSprites.h:798
jugimap::Sprite::GetPosition
Vec2f GetPosition(bool _includeAnimatedProperties=true)
Returns the position of this sprite.
Definition: jmSprites.cpp:316
jugimap::TextSprite::GetFont
Font * GetFont()
Returns the font of this text sprite.
Definition: jmSprites.h:906
jugimap::Sprite::MakePassiveCopy
Sprite * MakePassiveCopy()
Create a new sprite which is a passive copy of this sprite.
Definition: jmSprites.cpp:38
jugimap::TextSprite::GetSize
Vec2f GetSize()
Returns the size of this text sprite.
Definition: jmSprites.cpp:919
jugimap::GraphicItem
The GraphicItem class defines the equivalent object from JugiMap Editor.
Definition: jmSourceGraphics.h:34
jugimap::Sprite::GetId
int GetId()
Returns the id of this sprite.
Definition: jmSprites.h:225
jugimap::StandardSprite::~StandardSprite
virtual ~StandardSprite()
Destructor.
Definition: jmSprites.cpp:566
jugimap::ComposedSprite::InitEngineObjects
virtual void InitEngineObjects() override
Initialize the engine sprite.
Definition: jmSprites.cpp:1091
jugimap::Sprite::SetOwnBlend
void SetOwnBlend(Blend _blend)
Set the own blend of this sprite to the given **_blend**.
Definition: jmSprites.cpp:239
jugimap::Sprite::AppendToChangeFlags
void AppendToChangeFlags(int _changeFlags)
Append the given *_changeFlags* to the change flags of this sprite with a biwise operation....
Definition: jmSprites.cpp:303
jugimap::Sprite::GetAnimatedProperties
AnimatedProperties * GetAnimatedProperties()
Returns the pre-animation properties.
Definition: jmSprites.h:504
jugimap::StandardSprite::Overlaps
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
jugimap::Sprite::GetCustomObject
CustomObject * GetCustomObject()
Returns the custom object of this sprite if exists; otherwise returns nullptr.
Definition: jmSprites.h:268
jugimap::StandardSprite
The StandardSprite class defines the sprite from JugiMap Editor.
Definition: jmSprites.h:787
jugimap::Sprite::DrawEngineSprite
virtual void DrawEngineSprite()
Draw the engine sprite.
Definition: jmSprites.h:129
jugimap::Sprite::GetOverlayColorRGBA
ColorRGBA GetOverlayColorRGBA(bool _includeAnimatedProperties=true)
Returns the overlay color of this sprite.
Definition: jmSprites.cpp:500
jugimap::Sprite::GetParentComposedSprite
ComposedSprite * GetParentComposedSprite()
Returns the parent composed sprite of this sprite.
Definition: jmSprites.h:205
jugimap::Vec2::x
T x
The x coordinate.
Definition: jmCommon.h:25
jugimap::AffineMat3::Invert
AffineMat3< T > Invert() const
Returns a matrix formed by inverting this matrix.
Definition: jmCommon.h:281
jugimap::Sprite
The Sprite is the base sprite class.
Definition: jmSprites.h:32
jugimap::Sprite::SetColorOverlayActive
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
jugimap::Sprite::GetName
std::string GetName()
Returns the name of this sprite.
Definition: jmSprites.h:238
jugimap::Sprite::Overlaps
virtual bool Overlaps(Sprite *_sprite)
Returns true if the shapes of this and the given **_sprite** overelaps; otherwise returns false.
Definition: jmSprites.h:550
jugimap::Sprite::CreateAnimatedPropertiesIfNone
virtual void CreateAnimatedPropertiesIfNone()
Store current properties for animation purposes.
Definition: jmSprites.cpp:519
jugimap::TextSprite::CopyProperties
virtual void CopyProperties(Sprite *_sprite, int copyFlags) override
Copy properties from the given **_sprite**.
Definition: jmSprites.cpp:956
jugimap::ComposedSprite::ConvertToWorldFlip
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
jugimap::TextSprite::SetColor
void SetColor(ColorRGBA _color)
Set the color of this text sprite to the given _color.
Definition: jmSprites.cpp:890
jugimap::Sprite::GetKind
SpriteKind GetKind()
Returns the kind of this sprite.
Definition: jmSprites.cpp:147
jugimap::Sprite::GetScale
Vec2f GetScale(bool _includeAnimatedProperties=true)
Returns the horizontal and vertical scale factor of this sprite.
Definition: jmSprites.cpp:362
jugimap::StandardSprite::PointInside
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
jugimap::Sprite::SetVisible
virtual void SetVisible(bool _visible)
Set the visibility of this sprite.
Definition: jmSprites.cpp:133
jugimap::Sprite::GetParameters
std::vector< jugimap::Parameter > & GetParameters()
Returns a reference to the vector of stored parameters in this sprite.
Definition: jmSprites.h:277
jugimap::Sprite::RaycastHit
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
jugimap::Sprite::SetName
void SetName(const std::string &_nameID)
Set the name of this sprite to the given _nameID.
Definition: jmSprites.h:232
jugimap::TextSprite::GetHeight
float GetHeight()
Returns the height of this text sprite.
Definition: jmSprites.cpp:897
jugimap::TextSprite::GetRelativeHandle
Vec2f GetRelativeHandle()
Returns the relative handle of this text sprite.
Definition: jmSprites.h:958
jugimap::Sprite::SetFlip
void SetFlip(Vec2i _flip)
Set the horizontal and vertical flip factor of this sprite to the given **_flip**.
Definition: jmSprites.cpp:200
jugimap::Blend::NOT_DEFINED
The blend not defined.
jugimap::ComposedSprite::UpdateEngineObjects
virtual void UpdateEngineObjects() override
Update the engine sprite.
Definition: jmSprites.cpp:1108
jugimap::ComposedSprite::~ComposedSprite
virtual ~ComposedSprite() override
Destructor.
Definition: jmSprites.cpp:1081
jugimap::Vec2::y
T y
The y coordinate.
Definition: jmCommon.h:26
jugimap::Sprite::GetGlobalScale
Vec2f GetGlobalScale(bool _includeAnimatedProperties=true)
Returns the global scale factor of this sprite.
Definition: jmSprites.cpp:392
jugimap::Sprite::GetLayer
SpriteLayer * GetLayer()
Returns a sprite layer where this sprite is stored.
Definition: jmSprites.h:195
jugimap::Sprite::GetGlobalFlip
Vec2i GetGlobalFlip(bool _includeAnimatedProperties=true)
Returns the horizontal and vertical world flip factor of this sprite.
Definition: jmSprites.cpp:462
jugimap::TextSprite::PointInside
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
jugimap::Sprite::SetTag
void SetTag(int _tag)
Set the tag of this sprite to the given _tag.
Definition: jmSprites.h:246
jugimap::Rectf
Rect< float > Rectf
Rect struct in float precision.
Definition: jmCommon.h:257
jugimap::StandardSprite::RaycastHit
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
jugimap::StandardSprite::GetActiveImage
GraphicItem * GetActiveImage()
Returns the active image.
Definition: jmSprites.h:814
jugimap::Sprite::GetBoundingBox
Rectf GetBoundingBox()
Returns the world bounding rectangle of this sprite.
Definition: jmSprites.h:182
jugimap::ComposedSprite::PointInside
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
jugimap::Sprite::SetHandle
virtual void SetHandle(Vec2f _handle)
Set the handle point of this sprite to the given **_handle** point.
Definition: jmSprites.cpp:213
jugimap::Vec2f
Vec2< float > Vec2f
Vec2 struct in float precision.
Definition: jmCommon.h:167
jugimap::Sprite::GetOverlayColorBlend
ColorOverlayBlend GetOverlayColorBlend(bool _includeAnimatedProperties=true)
Returns the overlay color blend of this sprite.
Definition: jmSprites.cpp:509
jugimap::Sprite::GetTag
int GetTag()
Returns the tag of this sprite.
Definition: jmSprites.h:252
jugimap::SkeletonSprite::SkeletonSprite
SkeletonSprite()
Constructor.
Definition: jmSprites.h:1017
jugimap::SkeletonSprite
The SkeletonSprite class defines the skeleton sprite from JugiMap Editor.
Definition: jmSprites.h:1011
jugimap::Sprite::SetScale
void SetScale(Vec2f _scale)
Set the horizontal and vertical scale factor of this sprite to the given **_scale**.
Definition: jmSprites.cpp:174
jugimap::StandardSprite::GetPhysicsMode
virtual PhysicsMode GetPhysicsMode()
Returns the physics mode.
Definition: jmSprites.h:852
jugimap::TextSprite::InitEngineObjects
virtual void InitEngineObjects() override
Initialize the engine sprite.
Definition: jmSprites.cpp:788
jugimap::TextSprite::TextSprite
TextSprite()
Constructor.
Definition: jmSprites.h:895
jugimap::ComposedSprite::SetVisible
virtual void SetVisible(bool _visible) override
Set the visibility of this sprite.
Definition: jmSprites.cpp:1145
jugimap::Sprite::InitEngineObjects
virtual void InitEngineObjects()
Initialize the engine sprite.
Definition: jmSprites.h:116
jugimap::Sprite::ResetAnimatedProperties
virtual void ResetAnimatedProperties()
Set sprite properties to pre-animation state.
Definition: jmSprites.cpp:529
jugimap::ComposedSprite::Overlaps
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
jugimap::Sprite::~Sprite
virtual ~Sprite()
Destructor.
Definition: jmSprites.cpp:22
jugimap::Sprite::GetDataFlags
int GetDataFlags()
Returns the dataFlags of this sprite.
Definition: jmSprites.h:283
jugimap::StandardSprite::DYNAMIC
Included in the physics simulation as a dynamic object.
Definition: jmSprites.h:797
jugimap::Sprite::SetPosition
void SetPosition(Vec2f _position)
Set the position of this sprite to the given **_position**.
Definition: jmSprites.cpp:161
jugimap::AffineMat3::Transform
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
jugimap::Sprite::IsVisible
bool IsVisible()
Returns true if this sprite is visible; otherwise returns false.
Definition: jmSprites.h:150
jugimap::ComposedSprite::ComposedSprite
ComposedSprite()
Constructor.
Definition: jmSprites.h:691
jugimap::StandardSprite::StandardSprite
StandardSprite()
Constructor.
Definition: jmSprites.h:803
jugimap::Sprite::UpdateEngineObjects
virtual void UpdateEngineObjects()
Update the engine sprite.
Definition: jmSprites.h:122
jugimap::Sprite::HasCollider
virtual bool HasCollider()
Returns true if this sprite has assigned a collider; otherwise returns false.
Definition: jmSprites.h:536
jugimap::Font
The Font class defines fonts used in TextSprite objects.
Definition: jmFont.h:16
jugimap::AffineMat3
Matrix representation of the affine transformation.
Definition: jmCommon.h:263
jugimap::TextSprite::GetWidth
float GetWidth()
Returns the width of this text sprite.
Definition: jmSprites.cpp:908
jugimap::StandardSprite::UpdateBoundingBox
void UpdateBoundingBox() override
Update the map bounding box of this sprite.
Definition: jmSprites.cpp:575
jugimap::Blend
Blend
The blend modes for the openGL pixel blending.
Definition: jmGlobal.h:101
jugimap::Sprite::IsOverlayColorActive
bool IsOverlayColorActive()
Returns true if the overlay color of this sprite is active; otherwise returns false.
Definition: jmSprites.cpp:489
jugimap::Sprite::UpdateBoundingBox
virtual void UpdateBoundingBox()
Update the map bounding box of this sprite.
Definition: jmSprites.h:176
jugimap::Sprite::IsEngineSpriteUsedDirectly
bool IsEngineSpriteUsedDirectly()
Returns true if this sprite's engine sprite is used directly.
Definition: jmSprites.h:168
jugimap::TextSprite::UpdateBoundingBox
virtual void UpdateBoundingBox() override
Update the map bounding box of this sprite.
Definition: jmSprites.cpp:847
jugimap::ComposedSprite
The ComposedSprite class defines the composed sprite from JugiMap Editor.
Definition: jmSprites.h:682
jugimap::ComposedSprite::RaycastHit
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
jugimap::Sprite::GetSourceSprite
SourceSprite * GetSourceSprite()
Returns the source sprite of this sprite.
Definition: jmSprites.h:199
jugimap::Sprite::GetRotation
float GetRotation(bool _includeAnimatedProperties=true)
Returns the rotation of this sprite in degrees.
Definition: jmSprites.cpp:414
jugimap::StandardSprite::GetCollider
Collider * GetCollider()
Returns the collider or nullptr if none.
Definition: jmSprites.h:846
jugimap::Vec2
2d vector.
Definition: jmCommon.h:23
jugimap::SourceSprite
The SourceSprite class defines the source sprite from JugiMap Editor.
Definition: jmSourceGraphics.h:221
jugimap::Sprite::SetColorOverlayRGBA
void SetColorOverlayRGBA(ColorRGBA _colorOverlayRGBA)
Set the color overlay of this sprite to the given **_colorOverlayRGBA**.
Definition: jmSprites.cpp:265
jugimap::StandardSprite::SetPhysicsMode
virtual void SetPhysicsMode(PhysicsMode _physicsMode)
Set the physics mode to the given *_physicsMode*.
Definition: jmSprites.h:858
jugimap::ComposedSprite::GetLayers
std::vector< Layer * > & GetLayers()
Returns a reference to the vector of stored layers in this composed sprite.
Definition: jmSprites.h:736
jugimap::StandardSprite::HasCollider
virtual bool HasCollider() override
Returns true if this sprite has assigned a collider; otherwise returns false.
Definition: jmSprites.cpp:693
jugimap::ComposedSprite::DrawEngineSprite
virtual void DrawEngineSprite() override
Draw the engine sprite.
Definition: jmSprites.cpp:1134
jugimap::TextSprite
The TextSprite class defines the text sprite from JugiMap Editor.
Definition: jmSprites.h:889
jugimap::Sprite::GetFlip
Vec2i GetFlip(bool _includeAnimatedProperties=true)
Returns the horizontal and vertical flip factor of this sprite.
Definition: jmSprites.cpp:442
jugimap::SkeletonSprite::InitEngineObjects
virtual void InitEngineObjects() override
Initialize the engine sprite.
Definition: jmSprites.cpp:1358
jugimap::Sprite::SetCustomObject
void SetCustomObject(CustomObject *_customObject)
Assign a custom object of this sprite to the given _customObject.
Definition: jmSprites.h:262
jugimap::ComposedSprite::ConvertToWorldRotation
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
jugimap::Sprite::CaptureForLerpDrawing
virtual void CaptureForLerpDrawing()
Capture the sprite properties, usually the position only, required for the lerp drawing.
Definition: jmSprites.h:188
jugimap::JugiMapBinaryLoader
The JugiMapBinaryLoader class loads data from jugimap binary files (.jmb).
Definition: jmMapBinaryLoader.h:37
jugimap::Sprite::Sprite
Sprite()
Constructor.
Definition: jmSprites.h:72
jugimap::ComposedSprite::ConvertToWorldScale
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
jugimap::SpriteLayer
The SpriteLayer class defines the sprite and tile layers from JugiMap Editor.
Definition: jmLayers.h:303
jugimap::ColorOverlayBlend
ColorOverlayBlend
The blend modes for the shader based pixel blending which simulate photoshop blending modes.
Definition: jmGlobal.h:112
jugimap::Sprite::IsEngineSpriteInitialized
virtual bool IsEngineSpriteInitialized()
Returns true if the engine sprite of this sprite has been initialized; otherwise returns false.
Definition: jmSprites.h:135