mirror of https://github.com/axmolengine/axmol.git
198 lines
5.9 KiB
C
198 lines
5.9 KiB
C
|
/**
|
|||
|
* 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_WORLD_CLOCK_H
|
|||
|
#define DRAGONBONES_WORLD_CLOCK_H
|
|||
|
|
|||
|
#include "../core/DragonBones.h"
|
|||
|
#include "IAnimatable.h"
|
|||
|
|
|||
|
DRAGONBONES_NAMESPACE_BEGIN
|
|||
|
/**
|
|||
|
* - Worldclock provides clock support for animations, advance time for each IAnimatable object added to the instance.
|
|||
|
* @see dragonBones.IAnimateble
|
|||
|
* @see dragonBones.Armature
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - WorldClock <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ṩʱ<EFBFBD><EFBFBD>֧<EFBFBD>֣<EFBFBD>Ϊÿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>뵽<EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> IAnimatable <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䡣
|
|||
|
* @see dragonBones.IAnimateble
|
|||
|
* @see dragonBones.Armature
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
class WorldClock : public IAnimatable
|
|||
|
{
|
|||
|
DRAGONBONES_DISALLOW_COPY_AND_ASSIGN(WorldClock)
|
|||
|
|
|||
|
public:
|
|||
|
/**
|
|||
|
* - Deprecated, please refer to {@link dragonBones.BaseFactory#clock}.
|
|||
|
* @deprecated
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - <EFBFBD>ѷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ο<EFBFBD> {@link dragonBones.BaseFactory#clock}<EFBFBD><EFBFBD>
|
|||
|
* @deprecated
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
static WorldClock clock;
|
|||
|
|
|||
|
public:
|
|||
|
/**
|
|||
|
* - Current time. (In seconds)
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - <EFBFBD><EFBFBD>ǰ<EFBFBD><EFBFBD>ʱ<EFBFBD>䡣 (<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>λ)
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
float time;
|
|||
|
/**
|
|||
|
* - The play speed, used to control animation speed-shift play.
|
|||
|
* [0: Stop play, (0~1): Slow play, 1: Normal play, (1~N): Fast play]
|
|||
|
* @default 1.0
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٶȣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڿ<EFBFBD><EFBFBD>ƶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ٲ<EFBFBD><EFBFBD>š<EFBFBD>
|
|||
|
* [0: ֹͣ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, (0~1): <EFBFBD><EFBFBD><EFBFBD>ٲ<EFBFBD><EFBFBD><EFBFBD>, 1: <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>, (1~N): <EFBFBD><EFBFBD><EFBFBD>ٲ<EFBFBD><EFBFBD><EFBFBD>]
|
|||
|
* @default 1.0
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
float timeScale;
|
|||
|
|
|||
|
private:
|
|||
|
float _systemTime;
|
|||
|
std::vector<IAnimatable*> _animatebles;
|
|||
|
WorldClock* _clock;
|
|||
|
|
|||
|
public:
|
|||
|
/**
|
|||
|
* - Creating a Worldclock instance. Typically, you do not need to create Worldclock instance.
|
|||
|
* When multiple Worldclock instances are running at different speeds, can achieving some specific animation effects, such as bullet time.
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD> WorldClock ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><EFBFBD><EFBFBD><EFBFBD> WorldClock ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WorldClock ʵ<EFBFBD><EFBFBD>ʹ<EFBFBD>ò<EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>ٶ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʵ<EFBFBD><EFBFBD>һЩ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ķ<EFBFBD><EFBFBD><EFBFBD>Ч<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD>
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
WorldClock(float timeValue = 0.0f) :
|
|||
|
time(timeValue),
|
|||
|
timeScale(1.0f),
|
|||
|
_systemTime(0.0f),
|
|||
|
_animatebles(),
|
|||
|
_clock(nullptr)
|
|||
|
{
|
|||
|
_systemTime = 0.0f;
|
|||
|
}
|
|||
|
virtual ~WorldClock()
|
|||
|
{
|
|||
|
clear();
|
|||
|
}
|
|||
|
/**
|
|||
|
* - Advance time for all IAnimatable instances.
|
|||
|
* @param passedTime - Passed time. [-1: Automatically calculates the time difference between the current frame and the previous frame, [0~N): Passed time] (In seconds)
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - Ϊ<EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> IAnimatable ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䡣
|
|||
|
* @param passedTime - ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD>䡣 [-1: <EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>㵱ǰ֡<EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ֡<EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>, [0~N): ǰ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD>] (<EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD>λ)
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
virtual void advanceTime(float passedTime) override;
|
|||
|
/**
|
|||
|
* - Check whether contains a specific instance of IAnimatable.
|
|||
|
* @param value - The IAnimatable instance.
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD> IAnimatable ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param value - IAnimatable ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
bool contains(const IAnimatable* value) const;
|
|||
|
/**
|
|||
|
* - Add IAnimatable instance.
|
|||
|
* @param value - The IAnimatable instance.
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD> IAnimatable ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param value - IAnimatable ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
void add(IAnimatable* value);
|
|||
|
/**
|
|||
|
* - Removes a specified IAnimatable instance.
|
|||
|
* @param value - The IAnimatable instance.
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - <EFBFBD>Ƴ<EFBFBD><EFBFBD>ض<EFBFBD><EFBFBD><EFBFBD> IAnimatable ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @param value - IAnimatable ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
void remove(IAnimatable* value);
|
|||
|
/**
|
|||
|
* - Clear all IAnimatable instances.
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language en_US
|
|||
|
*/
|
|||
|
/**
|
|||
|
* - <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD> IAnimatable ʵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
* @version DragonBones 3.0
|
|||
|
* @language zh_CN
|
|||
|
*/
|
|||
|
void clear();
|
|||
|
/**
|
|||
|
* @inheritDoc
|
|||
|
*/
|
|||
|
inline virtual WorldClock* getClock() const override
|
|||
|
{
|
|||
|
return _clock;
|
|||
|
}
|
|||
|
virtual void setClock(WorldClock* value) override;
|
|||
|
|
|||
|
public: // For WebAssembly.
|
|||
|
static WorldClock* getStaticClock() { return &clock; }
|
|||
|
};
|
|||
|
|
|||
|
DRAGONBONES_NAMESPACE_END
|
|||
|
#endif // DRAGONBONES_WORLD_CLOCK_H
|