123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- #ifndef __MISC_NODE_CCPROGRESS_TIMER_H__
- #define __MISC_NODE_CCPROGRESS_TIMER_H__
- #include "renderer/CCCustomCommand.h"
- #include "2d/CCNode.h"
- NS_CC_BEGIN
- class Sprite;
- class CC_DLL ProgressTimer : public Node
- {
- public:
-
- enum class Type
- {
- RADIAL,
- BAR,
- };
-
-
- static ProgressTimer* create(Sprite* sp);
-
- Type getType() const { return _type; }
-
- float getPercentage() const { return _percentage; }
-
- Sprite* getSprite() const { return _sprite; }
-
-
- void setPercentage(float percentage);
-
-
- void setSprite(Sprite *sprite);
-
-
- void setType(Type type);
-
-
- bool isReverseDirection() { return _reverseDirection; };
-
-
- void setReverseDirection(bool value);
-
- CC_DEPRECATED_ATTRIBUTE void setReverseProgress(bool reverse) { setReverseDirection(reverse); }
-
- void setMidpoint(const Vec2& point);
-
-
- Vec2 getMidpoint() const;
-
- void setBarChangeRate(const Vec2& barChangeRate ) { _barChangeRate = barChangeRate; }
-
-
- Vec2 getBarChangeRate() const { return _barChangeRate; }
-
- virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
- virtual void setAnchorPoint(const Vec2& anchorPoint) override;
- virtual void setColor(const Color3B &color) override;
- virtual const Color3B& getColor() const override;
- virtual void setOpacity(GLubyte opacity) override;
- virtual GLubyte getOpacity() const override;
-
- CC_CONSTRUCTOR_ACCESS:
-
- ProgressTimer();
-
- virtual ~ProgressTimer();
-
-
- bool initWithSprite(Sprite* sp);
-
- protected:
- void onDraw(const Mat4 &transform, uint32_t flags);
-
- Tex2F textureCoordFromAlphaPoint(Vec2 alpha);
- Vec2 vertexFromAlphaPoint(Vec2 alpha);
- void updateProgress(void);
- void updateBar(void);
- void updateRadial(void);
- virtual void updateColor(void) override;
- Vec2 boundaryTexCoord(char index);
- Type _type;
- Vec2 _midpoint;
- Vec2 _barChangeRate;
- float _percentage;
- Sprite *_sprite;
- int _vertexDataCount;
- V2F_C4B_T2F *_vertexData;
-
- CustomCommand _customCommand;
- bool _reverseDirection;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(ProgressTimer);
- };
- NS_CC_END
- #endif
|