mirror of
https://github.com/smallmain/cocos-enhance-kit.git
synced 2025-10-09 22:05:24 +00:00
初始化
This commit is contained in:
@@ -0,0 +1,57 @@
|
||||
#include "EventObject.h"
|
||||
#include "../model/UserData.h"
|
||||
#include "../armature/Armature.h"
|
||||
|
||||
DRAGONBONES_NAMESPACE_BEGIN
|
||||
|
||||
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";
|
||||
const char* EventObject::FRAME_EVENT = "frameEvent";
|
||||
const char* EventObject::SOUND_EVENT = "soundEvent";
|
||||
|
||||
void EventObject::actionDataToInstance(const ActionData* data, EventObject* instance, Armature* armature)
|
||||
{
|
||||
if (data->type == ActionType::Play)
|
||||
{
|
||||
instance->type = EventObject::FRAME_EVENT;
|
||||
}
|
||||
else
|
||||
{
|
||||
instance->type = data->type == ActionType::Frame ? EventObject::FRAME_EVENT : EventObject::SOUND_EVENT;
|
||||
}
|
||||
|
||||
instance->name = data->name;
|
||||
instance->armature = armature;
|
||||
instance->actionData = data;
|
||||
instance->data = data->data;
|
||||
|
||||
if (data->bone != nullptr)
|
||||
{
|
||||
instance->bone = armature->getBone(data->bone->name);
|
||||
}
|
||||
|
||||
if (data->slot != nullptr)
|
||||
{
|
||||
instance->slot = armature->getSlot(data->slot->name);
|
||||
}
|
||||
}
|
||||
|
||||
void EventObject::_onClear()
|
||||
{
|
||||
time = 0.0f;
|
||||
type = "";
|
||||
name = "";
|
||||
armature = nullptr;
|
||||
bone = nullptr;
|
||||
slot = nullptr;
|
||||
animationState = nullptr;
|
||||
actionData = nullptr;
|
||||
data = nullptr;
|
||||
}
|
||||
|
||||
DRAGONBONES_NAMESPACE_END
|
267
cocos2d-x/cocos/editor-support/dragonbones/event/EventObject.h
Normal file
267
cocos2d-x/cocos/editor-support/dragonbones/event/EventObject.h
Normal file
@@ -0,0 +1,267 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef DRAGONBONES_EVENT_OBJECT_H
|
||||
#define DRAGONBONES_EVENT_OBJECT_H
|
||||
|
||||
#include "../core/BaseObject.h"
|
||||
|
||||
DRAGONBONES_NAMESPACE_BEGIN
|
||||
/**
|
||||
* - The properties of the object carry basic information about an event,
|
||||
* which are passed as parameter or parameter's parameter to event listeners when an event occurs.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 事件对象,包含有关事件的基本信息,当发生事件时,该实例将作为参数或参数的参数传递给事件侦听器。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
class EventObject : public BaseObject
|
||||
{
|
||||
BIND_CLASS_TYPE_A(EventObject);
|
||||
|
||||
public:
|
||||
/**
|
||||
* - Animation start play.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画开始播放。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* START;
|
||||
/**
|
||||
* - Animation loop play complete once.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画循环播放完成一次。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* LOOP_COMPLETE;
|
||||
/**
|
||||
* - Animation play complete.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画播放完成。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* COMPLETE;
|
||||
/**
|
||||
* - Animation fade in start.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画淡入开始。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* FADE_IN;
|
||||
/**
|
||||
* - Animation fade in complete.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画淡入完成。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* FADE_IN_COMPLETE;
|
||||
/**
|
||||
* - Animation fade out start.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画淡出开始。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* FADE_OUT;
|
||||
/**
|
||||
* - Animation fade out complete.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画淡出完成。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* FADE_OUT_COMPLETE;
|
||||
/**
|
||||
* - Animation frame event.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画帧事件。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* FRAME_EVENT;
|
||||
/**
|
||||
* - Animation frame sound event.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 动画帧声音事件。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
static const char* SOUND_EVENT;
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
static void actionDataToInstance(const ActionData* data, EventObject* instance, Armature* armature);
|
||||
|
||||
public:
|
||||
/**
|
||||
* - If is a frame event, the value is used to describe the time that the event was in the animation timeline. (In seconds)
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 如果是帧事件,此值用来描述该事件在动画时间轴中所处的时间。(以秒为单位)
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
float time;
|
||||
/**
|
||||
* - The event type。
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 事件类型。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
std::string type;
|
||||
/**
|
||||
* - The event name. (The frame event name or the frame sound name)
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 事件名称。 (帧事件的名称或帧声音的名称)
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
std::string name;
|
||||
/**
|
||||
* - The armature that dispatch the event.
|
||||
* @see dragonBones.Armature
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 发出该事件的骨架。
|
||||
* @see dragonBones.Armature
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
Armature* armature;
|
||||
/**
|
||||
* - The bone that dispatch the event.
|
||||
* @see dragonBones.Bone
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 发出该事件的骨骼。
|
||||
* @see dragonBones.Bone
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
Bone* bone;
|
||||
/**
|
||||
* - The slot that dispatch the event.
|
||||
* @see dragonBones.Slot
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 发出该事件的插槽。
|
||||
* @see dragonBones.Slot
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
Slot* slot;
|
||||
/**
|
||||
* - The animation state that dispatch the event.
|
||||
* @see dragonBones.AnimationState
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 发出该事件的动画状态。
|
||||
* @see dragonBones.AnimationState
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
AnimationState* animationState;
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
const ActionData* actionData;
|
||||
/**
|
||||
* - The custom data.
|
||||
* @see dragonBones.CustomData
|
||||
* @private
|
||||
* @version DragonBones 5.0
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 自定义数据。
|
||||
* @see dragonBones.CustomData
|
||||
* @private
|
||||
* @version DragonBones 5.0
|
||||
* @language zh_CN
|
||||
*/
|
||||
UserData* data;
|
||||
|
||||
protected:
|
||||
virtual void _onClear() override;
|
||||
|
||||
public: // For WebAssembly.
|
||||
Armature* getArmature() const { return armature; }
|
||||
Bone* getBone() const { return bone; }
|
||||
Slot* getSlot() const { return slot; }
|
||||
AnimationState* getAnimationState() const { return animationState; }
|
||||
UserData* getData() const { return data; }
|
||||
};
|
||||
DRAGONBONES_NAMESPACE_END
|
||||
#endif // DRAGONBONES_EVENT_OBJECT_H
|
@@ -0,0 +1,113 @@
|
||||
/**
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2012-2018 DragonBones team and other contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
* this software and associated documentation files (the "Software"), to deal in
|
||||
* the Software without restriction, including without limitation the rights to
|
||||
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
* the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
* subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
#ifndef DRAGONBONES_IEVENT_DISPATCHER_H
|
||||
#define DRAGONBONES_IEVENT_DISPATCHER_H
|
||||
|
||||
#include "../core/DragonBones.h"
|
||||
|
||||
DRAGONBONES_NAMESPACE_BEGIN
|
||||
/**
|
||||
* - The event dispatcher interface.
|
||||
* Dragonbones event dispatch usually relies on docking engine to implement, which defines the event method to be implemented when docking the engine.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 事件派发接口。
|
||||
* DragonBones 的事件派发通常依赖于对接的引擎来实现,该接口定义了对接引擎时需要实现的事件方法。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
class IEventDispatcher
|
||||
{
|
||||
ABSTRACT_CLASS(IEventDispatcher)
|
||||
|
||||
public:
|
||||
/**
|
||||
* - Checks whether the object has any listeners registered for a specific type of event。
|
||||
* @param type - Event type.
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 检查是否为特定的事件类型注册了任何侦听器。
|
||||
* @param type - 事件类型。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
virtual bool hasDBEventListener(const std::string& type) const = 0;
|
||||
/**
|
||||
* - Dispatches an event into the event flow.
|
||||
* @param type - Event type.
|
||||
* @param eventObject - Event object.
|
||||
* @see dragonBones.EventObject
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 分派特定的事件到事件流中。
|
||||
* @param type - 事件类型。
|
||||
* @param eventObject - 事件数据。
|
||||
* @see dragonBones.EventObject
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
virtual void dispatchDBEvent(const std::string& type, EventObject* value) = 0;
|
||||
/**
|
||||
* - Add an event listener object so that the listener receives notification of an event.
|
||||
* @param type - Event type.
|
||||
* @param listener - Event listener.
|
||||
* @param thisObject - The listener function's "this".
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 添加特定事件类型的事件侦听器,以使侦听器能够接收事件通知。
|
||||
* @param type - 事件类型。
|
||||
* @param listener - 事件侦听器。
|
||||
* @param thisObject - 侦听函数绑定的 this 对象。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
virtual void addDBEventListener(const std::string& type, const std::function<void(EventObject*)> & listener) = 0;
|
||||
/**
|
||||
* - Removes a listener from the object.
|
||||
* @param type - Event type.
|
||||
* @param listener - Event listener.
|
||||
* @param thisObject - The listener function's "this".
|
||||
* @version DragonBones 4.5
|
||||
* @language en_US
|
||||
*/
|
||||
/**
|
||||
* - 删除特定事件类型的侦听器。
|
||||
* @param type - 事件类型。
|
||||
* @param listener - 事件侦听器。
|
||||
* @param thisObject - 侦听函数绑定的 this 对象。
|
||||
* @version DragonBones 4.5
|
||||
* @language zh_CN
|
||||
*/
|
||||
virtual void removeDBEventListener(const std::string& type, const std::function<void(EventObject*)>& listener) = 0;
|
||||
};
|
||||
|
||||
DRAGONBONES_NAMESPACE_END
|
||||
#endif // DRAGONBONES_IEVENT_DISPATCHER_H
|
Reference in New Issue
Block a user