2012-04-19 14:35:52 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2010-2011 cocos2d-x.org
|
|
|
|
Copyright 2009 lhunath (Maarten Billemont)
|
|
|
|
|
|
|
|
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.
|
2012-04-17 16:00:18 +08:00
|
|
|
****************************************************************************/
|
|
|
|
#ifndef __CCACTIONTWEEN_H__
|
|
|
|
#define __CCACTIONTWEEN_H__
|
|
|
|
|
|
|
|
#include "CCActionInterval.h"
|
|
|
|
|
|
|
|
NS_CC_BEGIN
|
|
|
|
|
|
|
|
class CCActionTweenDelegate
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
virtual ~CCActionTweenDelegate() {}
|
|
|
|
virtual void updateTweenAction(float value, const char* key) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
/** CCActionTween
|
|
|
|
|
|
|
|
CCActionTween 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:
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
id modifyWidth = [CCActionTween actionWithDuration:2 key:@"width" from:200 to:300];
|
|
|
|
[target runAction:modifyWidth];
|
2012-04-17 16:00:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
Another example: CCScaleTo action could be rewriten using CCPropertyAction:
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
// scaleA and scaleB are equivalents
|
|
|
|
id scaleA = [CCScaleTo actionWithDuration:2 scale:3];
|
|
|
|
id scaleB = [CCActionTween actionWithDuration:2 key:@"scale" from:1 to:3];
|
2012-04-17 16:00:18 +08:00
|
|
|
|
|
|
|
|
|
|
|
@since v0.99.2
|
|
|
|
*/
|
|
|
|
class CCActionTween : public CCActionInterval
|
|
|
|
{
|
|
|
|
public:
|
2012-06-14 15:13:16 +08:00
|
|
|
/** creates an initializes the action with the property name (key), and the from and to parameters.
|
|
|
|
@warning: This interface will be deprecated in future.
|
|
|
|
*/
|
|
|
|
//static CCActionTween* actionWithDuration(float aDuration, const char* key, float from, float to);
|
2012-04-17 16:00:18 +08:00
|
|
|
/** creates an initializes the action with the property name (key), and the from and to parameters. */
|
2012-06-14 15:13:16 +08:00
|
|
|
static CCActionTween* create(float aDuration, const char* key, float from, float to);
|
2012-04-17 16:00:18 +08:00
|
|
|
/** initializes the action with the property name (key), and the from and to parameters. */
|
2012-06-08 13:55:28 +08:00
|
|
|
bool initWithDuration(float aDuration, const char* key, float from, float to);
|
2012-04-17 16:00:18 +08:00
|
|
|
|
|
|
|
void startWithTarget(CCNode *pTarget);
|
2012-06-08 13:55:28 +08:00
|
|
|
void update(float dt);
|
2012-04-17 16:00:18 +08:00
|
|
|
CCActionInterval* reverse();
|
|
|
|
|
2012-04-19 14:35:52 +08:00
|
|
|
std::string m_strKey;
|
|
|
|
float m_fFrom, m_fTo;
|
|
|
|
float m_fDelta;
|
2012-04-17 16:00:18 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
NS_CC_END
|
|
|
|
|
|
|
|
#endif /* __CCACTIONTWEEN_H__ */
|
|
|
|
|
|
|
|
|