axmol/extensions/DragonBones/event/EventObject.cpp

58 lines
1.6 KiB
C++
Raw Normal View History

2021-12-24 21:11:44 +08:00
#include "EventObject.h"
#include "../model/UserData.h"
#include "../armature/Armature.h"
DRAGONBONES_NAMESPACE_BEGIN
2021-12-25 10:04:45 +08:00
const char* EventObject::START = "start";
const char* EventObject::LOOP_COMPLETE = "loopComplete";
const char* EventObject::COMPLETE = "complete";
const char* EventObject::FADE_IN = "fadeIn";
const char* EventObject::FADE_IN_COMPLETE = "fadeInComplete";
const char* EventObject::FADE_OUT = "fadeOut";
const char* EventObject::FADE_OUT_COMPLETE = "fadeOutComplete";
2021-12-25 10:04:45 +08:00
const char* EventObject::FRAME_EVENT = "frameEvent";
const char* EventObject::SOUND_EVENT = "soundEvent";
void EventObject::actionDataToInstance(const ActionData* data, EventObject* instance, Armature* armature)
{
2021-12-25 10:04:45 +08:00
if (data->type == ActionType::Play)
{
instance->type = EventObject::FRAME_EVENT;
}
2021-12-25 10:04:45 +08:00
else
{
instance->type = data->type == ActionType::Frame ? EventObject::FRAME_EVENT : EventObject::SOUND_EVENT;
}
2021-12-25 10:04:45 +08:00
instance->name = data->name;
instance->armature = armature;
instance->actionData = data;
2021-12-25 10:04:45 +08:00
instance->data = data->data;
2021-12-25 10:04:45 +08:00
if (data->bone != nullptr)
{
instance->bone = armature->getBone(data->bone->name);
}
2021-12-25 10:04:45 +08:00
if (data->slot != nullptr)
{
instance->slot = armature->getSlot(data->slot->name);
}
}
void EventObject::_onClear()
{
2021-12-25 10:04:45 +08:00
time = 0.0f;
type = "";
name = "";
armature = nullptr;
bone = nullptr;
slot = nullptr;
animationState = nullptr;
2021-12-25 10:04:45 +08:00
actionData = nullptr;
data = nullptr;
}
DRAGONBONES_NAMESPACE_END