axmol/extensions/fairygui/GMovieClip.h

107 lines
2.7 KiB
C
Raw Normal View History

2020-08-04 12:31:33 +08:00
#ifndef __GMOVIECLIP_H__
#define __GMOVIECLIP_H__
#include "cocos2d.h"
#include "FairyGUIMacros.h"
#include "GObject.h"
NS_FGUI_BEGIN
class ActionMovieClip;
class GMovieClip : public GObject
{
public:
GMovieClip();
virtual ~GMovieClip();
CREATE_FUNC(GMovieClip);
bool isPlaying() const { return _playing; }
void setPlaying(bool value);
int getFrame() const;
void setFrame(int value);
float getTimeScale() const;
void setTimeScale(float value);
void advance(float time);
FlipType getFlip() const;
void setFlip(FlipType value);
2022-08-08 18:02:17 +08:00
ax::Color3B getColor() const { return _content->getColor(); }
void setColor(const ax::Color3B& value);
2020-08-04 12:31:33 +08:00
//from start to end(-1 means ending) repeat times(0 means infinite loop) when all is over, stopping at endAt(-1 means same value of end)
void setPlaySettings(int start = 0, int end = -1, int times = 0, int endAt = -1, std::function<void()> completeCallback = nullptr);
virtual void constructFromResource() override;
2022-08-08 18:02:17 +08:00
virtual ax::Value getProp(ObjectPropID propId) override;
virtual void setProp(ObjectPropID propId, const ax::Value& value) override;
2020-08-04 12:31:33 +08:00
protected:
virtual void handleInit() override;
virtual void setup_beforeAdd(ByteBuffer* buffer, int beginPos) override;
virtual void handleGrayedChanged() override;
private:
2022-08-08 18:02:17 +08:00
ax::Sprite* _content;
2020-08-04 12:31:33 +08:00
ActionMovieClip* _playAction;
bool _playing;
};
2022-08-08 18:02:17 +08:00
class ActionMovieClip : public ax::Action
2020-08-04 12:31:33 +08:00
{
public:
2022-08-08 18:02:17 +08:00
static ActionMovieClip* create(ax::Animation *animation, float repeatDelay = 0, bool swing =false);
2020-08-04 12:31:33 +08:00
ActionMovieClip();
~ActionMovieClip();
virtual bool isDone() const override;
virtual void step(float dt) override;
2022-08-08 18:02:17 +08:00
virtual void startWithTarget(ax::Node *target) override;
2020-08-04 12:31:33 +08:00
virtual ActionMovieClip* reverse() const override;
virtual ActionMovieClip* clone() const override;
int getFrame() { return _frame; }
void setFrame(int value);
float getTimeScale() const { return _timeScale; }
void setTimeScale(float value) { _timeScale = value; }
void advance(float time);
void setPlaySettings(int start, int end, int times, int endAt, std::function<void()> completeCallback = nullptr);
2022-08-08 18:02:17 +08:00
void setAnimation(ax::Animation *animation, float repeatDelay = 0, bool swing = false);
2020-08-04 12:31:33 +08:00
private:
void drawFrame();
2022-08-08 18:02:17 +08:00
ax::Animation* _animation;
2020-08-04 12:31:33 +08:00
int _frame;
float _frameElapsed;
int _repeatedCount;
bool _reversed;
float _timeScale;
float _repeatDelay;
bool _swing;
std::function<void()> _completeCallback;
int _displayFrame;
int _start;
int _end;
int _times;
int _endAt;
int _status; //0-none, 1-next loop, 2-ending, 3-ended
2022-07-15 19:17:01 +08:00
AX_DISALLOW_COPY_AND_ASSIGN(ActionMovieClip);
2020-08-04 12:31:33 +08:00
};
NS_FGUI_END
#endif