2021-12-26 23:26:34 +08:00
|
|
|
/**
|
2020-10-18 00:27:23 +08:00
|
|
|
* 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:
|
2021-12-25 10:04:45 +08:00
|
|
|
*
|
2020-10-18 00:27:23 +08:00
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
* copies or substantial portions of the Software.
|
2021-12-25 10:04:45 +08:00
|
|
|
*
|
2020-10-18 00:27:23 +08:00
|
|
|
* 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.
|
|
|
|
*/
|
2022-07-15 19:17:01 +08:00
|
|
|
#ifndef DRAGONBONES_AX_ARMATURE_DISPLAY_CONTAINER_H
|
|
|
|
#define DRAGONBONES_AX_ARMATURE_DISPLAY_CONTAINER_H
|
2020-10-18 00:27:23 +08:00
|
|
|
|
|
|
|
#include "DragonBones/DragonBonesHeaders.h"
|
|
|
|
#include "cocos2d.h"
|
|
|
|
|
|
|
|
DRAGONBONES_NAMESPACE_BEGIN
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
class CCArmatureDisplay : public axis::Node, public virtual IArmatureProxy
|
2020-10-18 00:27:23 +08:00
|
|
|
{
|
|
|
|
DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(CCArmatureDisplay)
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
|
|
|
static CCArmatureDisplay* create();
|
2021-12-25 10:04:45 +08:00
|
|
|
|
2020-10-18 00:27:23 +08:00
|
|
|
public:
|
|
|
|
bool debugDraw;
|
|
|
|
|
|
|
|
protected:
|
|
|
|
bool _debugDraw;
|
|
|
|
Armature* _armature;
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::EventDispatcher* _dispatcher;
|
2020-10-18 00:27:23 +08:00
|
|
|
|
|
|
|
public:
|
2021-12-25 10:04:45 +08:00
|
|
|
CCArmatureDisplay()
|
|
|
|
: debugDraw(false)
|
|
|
|
,
|
2020-10-18 00:27:23 +08:00
|
|
|
|
2021-12-25 10:04:45 +08:00
|
|
|
_debugDraw(false)
|
|
|
|
, _armature(nullptr)
|
|
|
|
, _dispatcher(nullptr)
|
2020-10-18 00:27:23 +08:00
|
|
|
{
|
2022-07-11 17:50:21 +08:00
|
|
|
_dispatcher = new axis::EventDispatcher();
|
2020-10-18 00:27:23 +08:00
|
|
|
setEventDispatcher(_dispatcher);
|
|
|
|
// _dispatcher->setEnabled(true);
|
|
|
|
}
|
|
|
|
virtual ~CCArmatureDisplay() {}
|
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
virtual void dbInit(Armature* armature) override;
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
virtual void dbClear() override;
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
virtual void dbUpdate() override;
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
virtual void dispose(bool disposeProxy = true) override;
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
inline virtual bool hasDBEventListener(std::string_view type) const override { return _dispatcher->isEnabled(); }
|
2020-10-18 00:27:23 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual void dispatchDBEvent(std::string_view type, EventObject* value) override;
|
2020-10-18 00:27:23 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-12-28 11:00:34 +08:00
|
|
|
virtual void addDBEventListener(std::string_view type, const std::function<void(EventObject*)>& listener) override;
|
2020-10-18 00:27:23 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-12-26 23:26:34 +08:00
|
|
|
virtual void removeDBEventListener(std::string_view type,
|
2021-12-25 10:04:45 +08:00
|
|
|
const std::function<void(EventObject*)>& listener) override;
|
2020-10-18 00:27:23 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
inline virtual Armature* getArmature() const override { return _armature; }
|
2020-10-18 00:27:23 +08:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-12-25 10:04:45 +08:00
|
|
|
inline virtual Animation* getAnimation() const override { return _armature->getAnimation(); }
|
2020-10-18 00:27:23 +08:00
|
|
|
/**
|
2021-12-25 10:04:45 +08:00
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual axis::Rect getBoundingBox() const override;
|
2020-10-18 00:27:23 +08:00
|
|
|
};
|
|
|
|
/**
|
|
|
|
* @internal
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
class DBCCSprite : public axis::Sprite
|
2020-10-18 00:27:23 +08:00
|
|
|
{
|
|
|
|
DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(DBCCSprite)
|
|
|
|
|
|
|
|
public:
|
|
|
|
static DBCCSprite* create();
|
|
|
|
|
|
|
|
protected:
|
|
|
|
DBCCSprite() {}
|
|
|
|
virtual ~DBCCSprite() {}
|
|
|
|
/**
|
|
|
|
* Modify for polyInfo rect
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
bool _checkVisibility(const axis::Mat4& transform, const axis::Size& size, const axis::Rect& rect);
|
2020-10-18 00:27:23 +08:00
|
|
|
|
|
|
|
public:
|
|
|
|
/**
|
|
|
|
* Modify for polyInfo rect
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
virtual void draw(axis::Renderer* renderer, const axis::Mat4& transform, uint32_t flags) override;
|
2020-10-18 00:27:23 +08:00
|
|
|
/**
|
|
|
|
* Modify for cocos2dx 3.7, 3.8, 3.9
|
|
|
|
*/
|
2022-07-11 17:50:21 +08:00
|
|
|
axis::PolygonInfo& getPolygonInfoModify();
|
2020-10-18 00:27:23 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
DRAGONBONES_NAMESPACE_END
|
2022-07-15 19:17:01 +08:00
|
|
|
#endif // DRAGONBONES_AX_ARMATURE_DISPLAY_CONTAINER_H
|