mirror of https://github.com/axmolengine/axmol.git
99 lines
3.1 KiB
C++
99 lines
3.1 KiB
C++
/****************************************************************************
|
|
Copyright (c) 2009 lhunath (Maarten Billemont)
|
|
Copyright (c) 2010-2012 cocos2d-x.org
|
|
CopyRight (c) 2013-2014 Chukong Technologies Inc.
|
|
|
|
http://www.cocos2d-x.org
|
|
|
|
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 __CCACTIONTWEEN_H__
|
|
#define __CCACTIONTWEEN_H__
|
|
|
|
#include "2d/CCActionInterval.h"
|
|
|
|
NS_CC_BEGIN
|
|
|
|
/**
|
|
* @addtogroup actions
|
|
* @{
|
|
*/
|
|
|
|
class CC_DLL ActionTweenDelegate
|
|
{
|
|
public:
|
|
/**
|
|
* @js NA
|
|
* @lua NA
|
|
*/
|
|
virtual ~ActionTweenDelegate() {}
|
|
virtual void updateTweenAction(float value, const std::string& key) = 0;
|
|
};
|
|
|
|
/** ActionTween
|
|
|
|
ActionTween is an action that lets you update any property of an object.
|
|
For example, if you want to modify the "width" property of a target from 200 to 300 in 2 seconds, then:
|
|
|
|
@code
|
|
auto modifyWidth = ActionTween::create(2, "width", 200, 300);
|
|
target->runAction(modifyWidth);
|
|
@endcode
|
|
|
|
Another example: ScaleTo action could be rewritten using PropertyAction:
|
|
|
|
@code
|
|
// scaleA and scaleB are equivalents
|
|
auto scaleA = ScaleTo::create(2, 3); // (duration, to)
|
|
auto scaleB = ActionTween::create(2, "scale", 1, 3); // (duration, key, from, to)
|
|
@endcode
|
|
|
|
@since v0.99.2
|
|
*/
|
|
class CC_DLL ActionTween : public ActionInterval
|
|
{
|
|
public:
|
|
/** creates an initializes the action with the property name (key), and the from and to parameters. */
|
|
static ActionTween* create(float duration, const std::string& key, float from, float to);
|
|
|
|
// Overrides
|
|
void startWithTarget(Node *target) override;
|
|
void update(float dt) override;
|
|
ActionTween* reverse() const override;
|
|
ActionTween *clone() const override;
|
|
|
|
CC_CONSTRUCTOR_ACCESS:
|
|
/** initializes the action with the property name (key), and the from and to parameters. */
|
|
bool initWithDuration(float duration, const std::string& key, float from, float to);
|
|
|
|
protected:
|
|
std::string _key;
|
|
float _from, _to;
|
|
float _delta;
|
|
};
|
|
|
|
// end of actions group
|
|
/// @}
|
|
|
|
NS_CC_END
|
|
|
|
#endif /* __CCACTIONTWEEN_H__ */
|
|
|
|
|