cocos2dx学习笔记:自定义动作实现圆周运动
From: http://cstriker1407.info/blog/cocos2dx-study-notes-custom-actions-realization-of-circular-motion/ 最近在翻帖子的时候发现很多大牛都自己实现自定义动作,而不是通过各种动作进行组合,正好最近需要一个圆周运动的效果,就自己写了一个自定义的动作,这里备注下大致的实现思路。 Contents[hide]
备注:
|
#ifndef __CIRCLE_MOVE_ACT_H__ |
//http://202.113.29.3/nankaisource/mathhands/Elementary%20mathematics/0103/010301/01030101.htm
class
CircleMoveAct :
public
cocos2d::CCActionInterval
{
:
bool
initWithDuration(
float
duration,
const
cocos2d::CCPoint& center,
scaleDiff,255)!important; border:0px!important; white-space:normal; margin:0px!important; outline:0px!important; text-align:left!important; float:none!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:auto!important; line-height:1.1em!important; font-weight:normal!important; font-style:normal!important; min-height:inherit!important">angle);
virtual
cocos2d::CCObject* copyWithZone(cocos2d::CCZone* pZone);
void
startWithTarget(cocos2d::CCNode *pTarget);
float
time
);
CircleMoveAct* create(
scale,61)!important; border:0px!important; white-space:normal; margin:0px!important; outline:0px!important; text-align:left!important; float:none!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:auto!important; line-height:1.1em!important; font-weight:bold!important; font-style:normal!important; min-height:inherit!important">protected
:
cocos2d::CCPoint m_center;
m_frameCnts;
CircleMoveAct.cpp:
CCPoint& center,255)!important; border:0px!important; white-space:normal; margin:0px!important; outline:0px!important; text-align:left!important; float:none!important; vertical-align:baseline!important; position:static!important; left:auto!important; top:auto!important; right:auto!important; bottom:auto!important; height:auto!important; width:auto!important; line-height:1.1em!important; font-weight:normal!important; font-style:normal!important; min-height:inherit!important">angle)
new
CircleMoveAct();
pRet;
CircleMoveAct::initWithDuration(
angle)
(CCActionInterval::initWithDuration(duration))
->m_duration = duration;
/************************************************************************/
true
;
CCObject* CircleMoveAct::copyWithZone(CCZone *pZone)
(pZone && pZone->m_pCopyObject)
CircleMoveAct();
CCZone(pCopy);
)