123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308 |
- #ifndef __SPRITE_CCSPRITE_FRAME_H__
- #define __SPRITE_CCSPRITE_FRAME_H__
- #include "2d/CCNode.h"
- #include "2d/CCAutoPolygon.h"
- #include "base/CCRef.h"
- #include "math/CCGeometry.h"
- NS_CC_BEGIN
- class Texture2D;
- class CC_DLL SpriteFrame : public Ref, public Clonable
- {
- public:
-
- static SpriteFrame* create(const std::string& filename, const Rect& rect);
-
-
- static SpriteFrame* create(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
-
-
- static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect);
-
- static SpriteFrame* createWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
-
-
- const Rect& getRectInPixels() const { return _rectInPixels; }
-
- void setRectInPixels(const Rect& rectInPixels);
-
- bool isRotated() const { return _rotated; }
-
- void setRotated(bool rotated) { _rotated = rotated; }
-
- const Rect& getRect() const { return _rect; }
-
- void setRect(const Rect& rect);
-
- const Rect& getCenterRect() const { return _centerRect; }
-
- void setCenterRectInPixels(const Rect& centerRect);
-
- bool hasCenterRect() const;
-
- const Vec2& getOffsetInPixels() const;
-
- void setOffsetInPixels(const Vec2& offsetInPixels);
-
- const Size& getOriginalSizeInPixels() const { return _originalSizeInPixels; }
-
- void setOriginalSizeInPixels(const Size& sizeInPixels) { _originalSizeInPixels = sizeInPixels; }
-
- const Size& getOriginalSize() const { return _originalSize; }
-
- void setOriginalSize(const Size& sizeInPixels) { _originalSize = sizeInPixels; }
-
- Texture2D* getTexture();
-
- void setTexture(Texture2D* pobTexture);
-
- const Vec2& getOffset() const;
-
- void setOffset(const Vec2& offsets);
-
- const Vec2& getAnchorPoint() const;
-
- void setAnchorPoint(const Vec2& anchorPoint);
-
- bool hasAnchorPoint() const;
-
- virtual SpriteFrame *clone() const override;
-
- void setPolygonInfo(const PolygonInfo &polygonInfo);
-
- const PolygonInfo& getPolygonInfo() const;
-
- bool hasPolygonInfo() const;
- CC_CONSTRUCTOR_ACCESS:
-
- SpriteFrame();
-
-
- virtual ~SpriteFrame();
-
-
- bool initWithTexture(Texture2D* pobTexture, const Rect& rect);
-
-
- bool initWithTextureFilename(const std::string& filename, const Rect& rect);
-
-
- bool initWithTexture(Texture2D* pobTexture, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
-
-
- bool initWithTextureFilename(const std::string& filename, const Rect& rect, bool rotated, const Vec2& offset, const Size& originalSize);
- protected:
- Vec2 _offset;
- Vec2 _anchorPoint;
- Size _originalSize;
- Rect _rectInPixels;
- bool _rotated;
- Rect _rect;
- Rect _centerRect;
- Vec2 _offsetInPixels;
- Size _originalSizeInPixels;
- Texture2D *_texture;
- std::string _textureFilename;
- PolygonInfo _polygonInfo;
- };
- NS_CC_END
- #endif
|