vs2012 supported
This commit is contained in:
parent
3ae122bc97
commit
0223ad2b93
|
|
@ -5,11 +5,27 @@ e2d::ActionSequence::ActionSequence()
|
|||
{
|
||||
}
|
||||
|
||||
e2d::ActionSequence::ActionSequence(const std::initializer_list<Action*>& vActions)
|
||||
#if HIGHER_THAN_VS2012
|
||||
e2d::ActionSequence::ActionSequence(const InitList<Action*>& vActions)
|
||||
: m_nActionIndex(0)
|
||||
{
|
||||
this->add(vActions);
|
||||
}
|
||||
#else
|
||||
e2d::ActionSequence::ActionSequence(int number, Action * action1, ...) :
|
||||
m_nActionIndex(0)
|
||||
{
|
||||
Action ** ppAction = &action1;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
WARN_IF((*ppAction) == nullptr, "ActionSequence NULL pointer exception!");
|
||||
this->add(*ppAction);
|
||||
ppAction++;
|
||||
number--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
e2d::ActionSequence::~ActionSequence()
|
||||
{
|
||||
|
|
@ -82,13 +98,28 @@ void e2d::ActionSequence::add(Action * action)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::ActionSequence::add(const std::initializer_list<Action*>& vActions)
|
||||
#if HIGHER_THAN_VS2012
|
||||
void e2d::ActionSequence::add(const InitList<Action*>& vActions)
|
||||
{
|
||||
for (const auto &action : vActions)
|
||||
{
|
||||
this->add(action);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void e2d::ActionSequence::add(int number, Action * action, ...)
|
||||
{
|
||||
Action ** ppAction = &action;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
WARN_IF((*ppAction) == nullptr, "ActionSequence NULL pointer exception!");
|
||||
this->add(*ppAction);
|
||||
ppAction++;
|
||||
number--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
e2d::ActionSequence * e2d::ActionSequence::clone() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,20 +12,56 @@ e2d::Animation::Animation(double interval)
|
|||
{
|
||||
}
|
||||
|
||||
e2d::Animation::Animation(const std::initializer_list<Image*>& vImages)
|
||||
#if HIGHER_THAN_VS2012
|
||||
|
||||
e2d::Animation::Animation(const InitList<Image*>& vImages)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(1)
|
||||
{
|
||||
this->add(vImages);
|
||||
}
|
||||
|
||||
e2d::Animation::Animation(double interval, const std::initializer_list<Image*>& vImages)
|
||||
e2d::Animation::Animation(double interval, const InitList<Image*>& vImages)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(interval)
|
||||
{
|
||||
this->add(vImages);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
e2d::Animation::Animation(int number, Image * frame, ...)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(1)
|
||||
{
|
||||
Image ** ppImage = &frame;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
WARN_IF((*ppImage) == nullptr, "Animation NULL pointer exception!");
|
||||
this->add(*ppImage);
|
||||
ppImage++;
|
||||
number--;
|
||||
}
|
||||
}
|
||||
|
||||
e2d::Animation::Animation(double interval, int number, Image * frame, ...)
|
||||
: m_nFrameIndex(0)
|
||||
, m_fInterval(interval)
|
||||
{
|
||||
Image ** ppImage = &frame;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
WARN_IF((*ppImage) == nullptr, "Animation NULL pointer exception!");
|
||||
this->add(*ppImage);
|
||||
ppImage++;
|
||||
number--;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
e2d::Animation::~Animation()
|
||||
{
|
||||
for (auto frame : m_vFrames)
|
||||
|
|
@ -86,13 +122,28 @@ void e2d::Animation::add(Image * frame)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::Animation::add(const std::initializer_list<Image*>& vImages)
|
||||
#if HIGHER_THAN_VS2012
|
||||
void e2d::Animation::add(const InitList<Image*>& vImages)
|
||||
{
|
||||
for (const auto &image : vImages)
|
||||
{
|
||||
this->add(image);
|
||||
}
|
||||
}
|
||||
#else
|
||||
void e2d::Animation::add(int number, Image * frame, ...)
|
||||
{
|
||||
Image ** ppImage = &frame;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
WARN_IF((*ppImage) == nullptr, "Animation NULL pointer exception!");
|
||||
this->add(*ppImage);
|
||||
ppImage++;
|
||||
number--;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
e2d::Animation * e2d::Animation::clone() const
|
||||
{
|
||||
|
|
|
|||
|
|
@ -53,13 +53,15 @@ void e2d::Scene::add(Node * child, int order /* = 0 */)
|
|||
m_pRoot->addChild(child, order);
|
||||
}
|
||||
|
||||
void e2d::Scene::add(const std::initializer_list<Node*>& vNodes, int order)
|
||||
#if HIGHER_THAN_VS2012
|
||||
void e2d::Scene::add(const InitList<Node*>& vNodes, int order)
|
||||
{
|
||||
for (const auto &node : vNodes)
|
||||
{
|
||||
this->add(node, order);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool e2d::Scene::remove(Node * child)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -602,13 +602,15 @@ void e2d::Node::addCollider(String collliderName)
|
|||
m_vColliders.insert(hash);
|
||||
}
|
||||
|
||||
void e2d::Node::addCollider(const std::initializer_list<String>& vCollliderName)
|
||||
#if HIGHER_THAN_VS2012
|
||||
void e2d::Node::addCollider(const InitList<String>& vCollliderName)
|
||||
{
|
||||
for (const auto &name : vCollliderName)
|
||||
{
|
||||
this->addCollider(name);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void e2d::Node::removeCollider(String collliderName)
|
||||
{
|
||||
|
|
@ -656,13 +658,15 @@ void e2d::Node::addChild(Node * child, int order /* = 0 */)
|
|||
}
|
||||
}
|
||||
|
||||
void e2d::Node::addChild(const std::initializer_list<Node*>& vNodes, int order)
|
||||
#if HIGHER_THAN_VS2012
|
||||
void e2d::Node::addChild(const InitList<Node*>& vNodes, int order)
|
||||
{
|
||||
for (const auto &node : vNodes)
|
||||
{
|
||||
this->addChild(node, order);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
e2d::Node * e2d::Node::getParent() const
|
||||
{
|
||||
|
|
|
|||
159
core/eactions.h
159
core/eactions.h
|
|
@ -400,10 +400,19 @@ public:
|
|||
// 创建顺序动作
|
||||
ActionSequence();
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 创建顺序动作
|
||||
ActionSequence(
|
||||
const std::initializer_list<Action*>& vActions /* 动作数组 */
|
||||
const InitList<Action*>& vActions /* 动作数组 */
|
||||
);
|
||||
#else
|
||||
// 创建顺序动作
|
||||
ActionSequence(
|
||||
int number, /* 动作数量 */
|
||||
Action * action, /* 第一个动作 */
|
||||
...
|
||||
);
|
||||
#endif
|
||||
|
||||
virtual ~ActionSequence();
|
||||
|
||||
|
|
@ -412,10 +421,19 @@ public:
|
|||
Action * action
|
||||
);
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 在结尾添加多个动作
|
||||
void add(
|
||||
const std::initializer_list<Action*>& vActions /* 动作数组 */
|
||||
const InitList<Action*>& vActions /* 动作数组 */
|
||||
);
|
||||
#else
|
||||
// 在结尾添加多个动作
|
||||
void add(
|
||||
int number, /* 动作数量 */
|
||||
Action * action, /* 第一个动作 */
|
||||
...
|
||||
);
|
||||
#endif
|
||||
|
||||
// 获取该动作的拷贝对象
|
||||
virtual ActionSequence * clone() const override;
|
||||
|
|
@ -515,16 +533,33 @@ public:
|
|||
double interval /* 帧间隔(秒) */
|
||||
);
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 创建帧动画
|
||||
Animation(
|
||||
const std::initializer_list<Image*>& vImages /* 关键帧数组 */
|
||||
const InitList<Image*>& vImages /* 关键帧数组 */
|
||||
);
|
||||
|
||||
// 创建特定帧间隔的帧动画
|
||||
Animation(
|
||||
double interval, /* 帧间隔(秒) */
|
||||
const InitList<Image*>& vImages /* 关键帧数组 */
|
||||
);
|
||||
#else
|
||||
// 创建帧动画
|
||||
Animation(
|
||||
int number, /* 帧数量 */
|
||||
Image * frame, /* 第一帧 */
|
||||
...
|
||||
);
|
||||
|
||||
// 创建特定帧间隔的帧动画
|
||||
Animation(
|
||||
double interval, /* 帧间隔(秒) */
|
||||
const std::initializer_list<Image*>& vImages /* 关键帧数组 */
|
||||
int number, /* 帧数量 */
|
||||
Image * frame, /* 第一帧 */
|
||||
...
|
||||
);
|
||||
#endif
|
||||
|
||||
virtual ~Animation();
|
||||
|
||||
|
|
@ -533,10 +568,19 @@ public:
|
|||
Image * frame /* 关键帧 */
|
||||
);
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 添加多个关键帧
|
||||
void add(
|
||||
const std::initializer_list<Image*>& vImages /* 关键帧数组 */
|
||||
const InitList<Image*>& vImages /* 关键帧数组 */
|
||||
);
|
||||
#else
|
||||
// 添加多个关键帧
|
||||
void add(
|
||||
int number, /* 帧数量 */
|
||||
Image * frame, /* 第一帧 */
|
||||
...
|
||||
);
|
||||
#endif
|
||||
|
||||
// 设置每一帧的时间间隔
|
||||
void setInterval(
|
||||
|
|
@ -647,12 +691,12 @@ namespace e2d
|
|||
|
||||
// 创建淡入动画
|
||||
ActionFadeIn* FadeIn(
|
||||
double duration /* 动画持续时长 */
|
||||
double duration /* 动画持续时长 */
|
||||
);
|
||||
|
||||
// 创建淡出动画
|
||||
ActionFadeOut* FadeOut(
|
||||
double duration /* 动画持续时长 */
|
||||
double duration /* 动画持续时长 */
|
||||
);
|
||||
|
||||
// 创建相对旋转动画
|
||||
|
|
@ -674,14 +718,9 @@ namespace e2d
|
|||
bool bAtSameTime = false /* 同时开始 */
|
||||
);
|
||||
|
||||
// 创建顺序动作
|
||||
ActionSequence* Sequence(
|
||||
const std::initializer_list<Action*>& vActions /* 动作数组 */
|
||||
);
|
||||
|
||||
// 创建延时动作
|
||||
ActionDelay* Delay(
|
||||
double duration /* 延迟时长(秒) */
|
||||
double duration /* 延迟时长(秒) */
|
||||
);
|
||||
|
||||
// 创建循环动作
|
||||
|
|
@ -690,16 +729,38 @@ namespace e2d
|
|||
int times = -1 /* 循环次数 */
|
||||
);
|
||||
|
||||
// 创建特定帧间隔的帧动画
|
||||
Animation* Animate(
|
||||
double interval, /* 帧间隔(秒) */
|
||||
const std::initializer_list<Image*>& vFrames /* 关键帧数组 */
|
||||
);
|
||||
|
||||
// 创建执行函数对象的动作
|
||||
ActionFunc* Func(
|
||||
Function func /* 函数对象 */
|
||||
Function func /* 函数对象 */
|
||||
);
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 创建顺序动作
|
||||
ActionSequence* Sequence(
|
||||
const InitList<Action*>& vActions /* 动作数组 */
|
||||
);
|
||||
|
||||
// 创建特定帧间隔的帧动画
|
||||
Animation* Animate(
|
||||
double interval, /* 帧间隔(秒) */
|
||||
const InitList<Image*>& vFrames /* 关键帧数组 */
|
||||
);
|
||||
#else
|
||||
// 创建顺序动作
|
||||
ActionSequence* Sequence(
|
||||
int number, /* 动作数量 */
|
||||
Action * action1, /* 第一个动作 */
|
||||
...
|
||||
);
|
||||
|
||||
// 创建特定帧间隔的帧动画
|
||||
Animation* Animate(
|
||||
double interval, /* 帧间隔(秒) */
|
||||
int number, /* 帧数量 */
|
||||
Image * frame, /* 第一帧 */
|
||||
...
|
||||
);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline e2d::ActionMoveBy * e2d::action::MoveBy(double duration, Vector vector)
|
||||
|
|
@ -767,11 +828,6 @@ namespace e2d
|
|||
return new (std::nothrow) ActionTwo(pActionFirst, pActionSecond, bAtSameTime);
|
||||
}
|
||||
|
||||
inline e2d::ActionSequence * e2d::action::Sequence(const std::initializer_list<Action*>& vActions)
|
||||
{
|
||||
return new (std::nothrow) ActionSequence(vActions);
|
||||
}
|
||||
|
||||
inline e2d::ActionDelay * e2d::action::Delay(double duration)
|
||||
{
|
||||
return new (std::nothrow) ActionDelay(duration);
|
||||
|
|
@ -782,13 +838,56 @@ namespace e2d
|
|||
return new (std::nothrow) ActionLoop(action, times);
|
||||
}
|
||||
|
||||
inline e2d::Animation * e2d::action::Animate(double interval, const std::initializer_list<Image*>& vFrames)
|
||||
{
|
||||
return new (std::nothrow) Animation(interval, vFrames);
|
||||
}
|
||||
|
||||
inline e2d::ActionFunc * e2d::action::Func(Function func)
|
||||
{
|
||||
return new (std::nothrow) ActionFunc(func);
|
||||
}
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
inline e2d::ActionSequence * e2d::action::Sequence(const InitList<Action*>& vActions)
|
||||
{
|
||||
return new (std::nothrow) ActionSequence(vActions);
|
||||
}
|
||||
|
||||
inline e2d::Animation * e2d::action::Animate(double interval, const InitList<Image*>& vFrames)
|
||||
{
|
||||
return new (std::nothrow) Animation(interval, vFrames);
|
||||
}
|
||||
#else
|
||||
inline e2d::ActionSequence * e2d::action::Sequence(int number, Action * action1, ...)
|
||||
{
|
||||
auto action = new (std::nothrow) ActionSequence();
|
||||
if (action)
|
||||
{
|
||||
Action ** ppAction = &action1;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
WARN_IF((*ppAction) == nullptr, "ActionSequence NULL pointer exception!");
|
||||
action->add(*ppAction);
|
||||
ppAction++;
|
||||
number--;
|
||||
}
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
inline e2d::Animation * e2d::action::Animate(double interval, int number, Image * frame, ...)
|
||||
{
|
||||
auto animation = new (std::nothrow) Animation(interval);
|
||||
if (animation)
|
||||
{
|
||||
Image ** ppImage = &frame;
|
||||
|
||||
while (number > 0)
|
||||
{
|
||||
WARN_IF((*ppImage) == nullptr, "Animation NULL pointer exception!");
|
||||
animation->add(*ppImage);
|
||||
ppImage++;
|
||||
number--;
|
||||
}
|
||||
}
|
||||
return animation;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -10,6 +10,26 @@ namespace e2d
|
|||
{
|
||||
|
||||
|
||||
// 函数对象
|
||||
typedef std::function<void()> Function;
|
||||
|
||||
// 创建函数对象
|
||||
template<typename Object, typename Func>
|
||||
inline Function CreateFunc(Object&& obj, Func&& func)
|
||||
{
|
||||
return std::bind(func, obj);
|
||||
}
|
||||
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
|
||||
// 初始化列表
|
||||
template <typename T>
|
||||
using InitList = std::initializer_list<T>;
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
struct Size;
|
||||
|
||||
// 表示坐标的结构体
|
||||
|
|
@ -54,17 +74,6 @@ struct Size
|
|||
};
|
||||
|
||||
|
||||
// 函数对象
|
||||
typedef std::function<void()> Function;
|
||||
|
||||
// 创建函数对象
|
||||
template<typename Object, typename Func>
|
||||
inline Function CreateFunc(Object&& obj, Func&& func)
|
||||
{
|
||||
return std::bind(func, obj);
|
||||
}
|
||||
|
||||
|
||||
// 字符串
|
||||
class String
|
||||
{
|
||||
|
|
@ -558,11 +567,13 @@ public:
|
|||
int zOrder = 0 /* 渲染顺序 */
|
||||
);
|
||||
|
||||
// 添加节点到场景
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 添加多个节点到场景
|
||||
virtual void add(
|
||||
const std::initializer_list<Node*>& vNodes, /* 节点数组 */
|
||||
int order = 0 /* 渲染顺序 */
|
||||
const InitList<Node*>& vNodes, /* 节点数组 */
|
||||
int order = 0 /* 渲染顺序 */
|
||||
);
|
||||
#endif
|
||||
|
||||
// 删除子节点
|
||||
bool remove(
|
||||
|
|
@ -572,9 +583,9 @@ public:
|
|||
// 获取根节点
|
||||
Node * getRoot() const;
|
||||
|
||||
// 开启几何图形的渲染
|
||||
void setShapeVisiable(
|
||||
bool visiable
|
||||
// 开启或关闭节点轮廓渲染
|
||||
void showOutline(
|
||||
bool visiable = true
|
||||
);
|
||||
|
||||
protected:
|
||||
|
|
|
|||
|
|
@ -70,4 +70,11 @@ EXTERN_C IMAGE_DOS_HEADER __ImageBase;
|
|||
#else
|
||||
#define WARN_IF(expression, message, ...) ((void)0)
|
||||
#endif //DEBUG || _DEBUG
|
||||
#endif
|
||||
|
||||
|
||||
#if _MSC_VER <= 1700
|
||||
#define HIGHER_THAN_VS2012 1
|
||||
#else
|
||||
#define HIGHER_THAN_VS2012 0
|
||||
#endif
|
||||
|
|
@ -326,10 +326,12 @@ public:
|
|||
String collliderName
|
||||
);
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 添加多个可碰撞节点的名称
|
||||
virtual void addCollider(
|
||||
const std::initializer_list<String>& vCollliderName /* 名称数组 */
|
||||
const InitList<String>& vCollliderName /* 名称数组 */
|
||||
);
|
||||
#endif
|
||||
|
||||
// 移除可碰撞节点的名称
|
||||
virtual void removeCollider(
|
||||
|
|
@ -342,11 +344,13 @@ public:
|
|||
int order = 0 /* 渲染顺序 */
|
||||
);
|
||||
|
||||
#if HIGHER_THAN_VS2012
|
||||
// 添加多个子节点
|
||||
virtual void addChild(
|
||||
const std::initializer_list<Node*>& vNodes, /* 节点数组 */
|
||||
const InitList<Node*>& vNodes, /* 节点数组 */
|
||||
int order = 0 /* 渲染顺序 */
|
||||
);
|
||||
#endif
|
||||
|
||||
// 执行动画
|
||||
virtual void runAction(
|
||||
|
|
|
|||
Loading…
Reference in New Issue