123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- #ifndef __CCMOTION_STREAK_H__
- #define __CCMOTION_STREAK_H__
- #include "base/CCProtocols.h"
- #include "2d/CCNode.h"
- #include "renderer/CCCustomCommand.h"
- NS_CC_BEGIN
- class Texture2D;
- class CC_DLL MotionStreak : public Node, public TextureProtocol
- {
- public:
-
- static MotionStreak* create(float timeToFade, float minSeg, float strokeWidth, const Color3B& strokeColor, const std::string& imagePath);
-
- static MotionStreak* create(float timeToFade, float minSeg, float strokeWidth, const Color3B& strokeColor, Texture2D* texture);
-
- void tintWithColor(const Color3B& colors);
-
- void reset();
-
- bool isFastMode() const { return _fastMode; }
-
- void setFastMode(bool bFastMode) { _fastMode = bFastMode; }
-
- float getStroke() const { return _stroke; }
-
- void setStroke(float stroke) { _stroke = stroke; }
-
- bool isStartingPositionInitialized() const { return _startingPositionInitialized; }
-
- void setStartingPositionInitialized(bool bStartingPositionInitialized)
- {
- _startingPositionInitialized = bStartingPositionInitialized;
- }
-
- virtual void setPosition(const Vec2& position) override;
- virtual void setPosition(float x, float y) override;
- virtual const Vec2& getPosition() const override;
- virtual void getPosition(float* x, float* y) const override;
- virtual void setPositionX(float x) override;
- virtual void setPositionY(float y) override;
- virtual float getPositionX(void) const override;
- virtual float getPositionY(void) const override;
- virtual Vec3 getPosition3D() const override;
-
- virtual void draw(Renderer *renderer, const Mat4 &transform, uint32_t flags) override;
-
- virtual void update(float delta) override;
- virtual Texture2D* getTexture() const override;
- virtual void setTexture(Texture2D *texture) override;
-
- virtual void setBlendFunc(const BlendFunc &blendFunc) override;
-
- virtual const BlendFunc& getBlendFunc() const override;
- virtual GLubyte getOpacity() const override;
- virtual void setOpacity(GLubyte opacity) override;
- virtual void setOpacityModifyRGB(bool value) override;
- virtual bool isOpacityModifyRGB() const override;
-
- CC_CONSTRUCTOR_ACCESS:
- MotionStreak();
- virtual ~MotionStreak();
-
-
- bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, const std::string& path);
-
-
- bool initWithFade(float fade, float minSeg, float stroke, const Color3B& color, Texture2D* texture);
- protected:
-
- void onDraw(const Mat4 &transform, uint32_t flags);
- bool _fastMode;
- bool _startingPositionInitialized;
-
- Texture2D* _texture;
- BlendFunc _blendFunc;
- Vec2 _positionR;
- float _stroke;
- float _fadeDelta;
- float _minSeg;
- unsigned int _maxPoints;
- unsigned int _nuPoints;
- unsigned int _previousNuPoints;
-
- Vec2* _pointVertexes;
- float* _pointState;
-
- Vec2* _vertices;
- GLubyte* _colorPointer;
- Tex2F* _texCoords;
-
- CustomCommand _customCommand;
- private:
- CC_DISALLOW_COPY_AND_ASSIGN(MotionStreak);
- };
- NS_CC_END
- #endif
|