cocos2dx全屏抖动,个别对象抖动
- /**
- desc:让指定控件抖动
- 一个CCNode同时执行多个CCShake动作,或者一个CCShake没有完又执行一个CCShake的话就会出现问题,会出现偏移的现象!
- 解决方案:
- 1).不要同时执行多个CCShake动作.
- 2.自己外部记录这个CCNode的位置,执行完成后手动setPosition();
- */
- #ifndef__SHAKE_H__
- #define__SHAKE_H__
- #include"actions/CCActionInterval.h"
- /**
- *按指定频度范围内抖动[-strength_x,strength_x][-strength_y,strength_y]
- classCCShake:publiccocos2d::CCActionInterval
- {
- public:
- CCShake();
- //Createtheactionwithatimeandastrength(sameinxandy)
- staticCCShake*create(floatd,floatstrength);
- //Createtheactionwithatimeandstrengths(differentinxandy)
- staticCCShake*createWithStrength(floatstrength_x,87); font-weight:bold; background-color:inherit">floatstrength_y);
- boolinitWithDuration(floatstrength_y);
- protected:
- virtualvoidstartWithTarget(cocos2d::CCNode*pTarget);
- voidupdate(floattime);
- voidstop(void);
- //Initialpositionoftheshakednode
- floatm_initial_x,m_initial_y;
- //Strengthoftheaction
- floatm_strength_x,m_strength_y;
- };
- *线性抖动(剩余时间越短,抖动范围越小)
- classCCFallOffShake:publicCCShake
- CCFallOffShake();
- staticCCFallOffShake*create(staticCCFallOffShake*createWithStrength(protected:
- floattime);
- #endif//__SHAKE_H__
copy