CCActionProgressTimer(进度条动作)
2014-05-21 17:41
176 查看
需要先看CCProgressTimer.h
#ifndef __ACTION_CCPROGRESS_TIMER_H__
#define __ACTION_CCPROGRESS_TIMER_H__
#include "CCActionInterval.h"
NS_CC_BEGIN
/**
@brief Progress to percentage
@since v0.99.1
*/
class CC_DLL CCProgressTo : public CCActionInterval
{
public:
/** Initializes with a duration and a percent */
bool initWithDuration(float duration, float fPercent); //动作时间,显示百分比
virtual CCObject* copyWithZone(CCZone *pZone);
virtual void startWithTarget(CCNode *pTarget);
///////
void CCProgressTo::startWithTarget(CCNode *pTarget)
{
CCActionInterval::startWithTarget(pTarget);
m_fFrom = ((kProgressTimerCast)(pTarget))->getPercentage();
// XXX: Is this correct ?
// Adding it to support CCRepeat
if (m_fFrom == 100)
{
m_fFrom = 0;
}
}
///////
virtual void update(float time);
//////
void CCProgressTo::update(float time)
{
((kProgressTimerCast)(m_pTarget))->setPercentage(m_fFrom + (m_fTo - m_fFrom) * time);
//#define kProgressTimerCast CCProgressTimer* // CCProgressTimer见CCProgressTimer.h
}
///////
public:
/** Creates and initializes with a duration and a percent */
static CCProgressTo* create(float duration, float fPercent);
protected:
float m_fTo;
float m_fFrom;
//默认 不可设置
};
/**
@brief Progress from a percentage to another percentage
@since v0.99.1
*/
class CC_DLL CCProgressFromTo : public CCActionInterval //可以设置from 和 to 百分比
{
public:
/** Initializes the action with a duration, a "from" percentage and a "to" percentage */
bool initWithDuration(float duration, float fFromPercentage, float fToPercentage);
virtual CCObject* copyWithZone(CCZone *pZone);
virtual CCActionInterval* reverse(void);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
public:
/** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */
static CCProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage);
protected:
float m_fTo;
float m_fFrom;
};
// end of actions group
/// @}
NS_CC_END
#endif // __ACTION_CCPROGRESS_TIMER_H__
#ifndef __ACTION_CCPROGRESS_TIMER_H__
#define __ACTION_CCPROGRESS_TIMER_H__
#include "CCActionInterval.h"
NS_CC_BEGIN
/**
@brief Progress to percentage
@since v0.99.1
*/
class CC_DLL CCProgressTo : public CCActionInterval
{
public:
/** Initializes with a duration and a percent */
bool initWithDuration(float duration, float fPercent); //动作时间,显示百分比
virtual CCObject* copyWithZone(CCZone *pZone);
virtual void startWithTarget(CCNode *pTarget);
///////
void CCProgressTo::startWithTarget(CCNode *pTarget)
{
CCActionInterval::startWithTarget(pTarget);
m_fFrom = ((kProgressTimerCast)(pTarget))->getPercentage();
// XXX: Is this correct ?
// Adding it to support CCRepeat
if (m_fFrom == 100)
{
m_fFrom = 0;
}
}
///////
virtual void update(float time);
//////
void CCProgressTo::update(float time)
{
((kProgressTimerCast)(m_pTarget))->setPercentage(m_fFrom + (m_fTo - m_fFrom) * time);
//#define kProgressTimerCast CCProgressTimer* // CCProgressTimer见CCProgressTimer.h
}
///////
public:
/** Creates and initializes with a duration and a percent */
static CCProgressTo* create(float duration, float fPercent);
protected:
float m_fTo;
float m_fFrom;
//默认 不可设置
};
/**
@brief Progress from a percentage to another percentage
@since v0.99.1
*/
class CC_DLL CCProgressFromTo : public CCActionInterval //可以设置from 和 to 百分比
{
public:
/** Initializes the action with a duration, a "from" percentage and a "to" percentage */
bool initWithDuration(float duration, float fFromPercentage, float fToPercentage);
virtual CCObject* copyWithZone(CCZone *pZone);
virtual CCActionInterval* reverse(void);
virtual void startWithTarget(CCNode *pTarget);
virtual void update(float time);
public:
/** Creates and initializes the action with a duration, a "from" percentage and a "to" percentage */
static CCProgressFromTo* create(float duration, float fFromPercentage, float fToPercentage);
protected:
float m_fTo;
float m_fFrom;
};
// end of actions group
/// @}
NS_CC_END
#endif // __ACTION_CCPROGRESS_TIMER_H__
相关文章推荐
- Cocos2d基于CCProgressTimer的倒计时进度条
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- cocos2d-x 之 CCProgressTimer 以及扩展实现颜色渐变进度条等等
- cocos2d-x学习(5)-------CCProgressTimer(进度条)
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- CCProgressTimer进度条
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条实现“理想”游戏进度条! 推荐
- CCActionTiledGrid与CCActionProgressTimer,源码分析
- CCProgressTimer(进度条)
- 详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- 【iOS-Cocos2d游戏开发之十五】详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- cocos2d-x 之 CCProgressTimer 以及扩展实现颜色渐变进度条等等
- ActionProgress: CCProgressTo 和 CCProgressTimer
- 详解CCProgressTimer 进度条并修改cocos2d源码实现“理想”游戏进度条!
- CCProgressTimer进度条比LoadingBar靠谱
- cocos2d-x节点(CCActionProgressTimer.h)API
- CCParallaxNode CCProgressTimer CCRibbon CCMotionStreak
- cocos2d-x TestLua 之 CCProgressTimer
- 【Cocos2d-X开发学习笔记】第19期:动作管理类(CCActionManager)的使用