axmol/extensions/fairygui/GMovieClip.h

107 lines
2.8 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);
axis::Color3B getColor() const { return _content->getColor(); }
void setColor(const axis::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;
virtual axis::Value getProp(ObjectPropID propId) override;
virtual void setProp(ObjectPropID propId, const axis::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:
axis::Sprite* _content;
2020-08-04 12:31:33 +08:00
ActionMovieClip* _playAction;
bool _playing;
};
class ActionMovieClip : public axis::Action
2020-08-04 12:31:33 +08:00
{
public:
static ActionMovieClip* create(axis::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;
virtual void startWithTarget(axis::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);
void setAnimation(axis::Animation *animation, float repeatDelay = 0, bool swing = false);
2020-08-04 12:31:33 +08:00
private:
void drawFrame();
axis::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