永发信息网

cocos2d-x 如何指定Sprite 抖动效果!

答案:2  悬赏:50  手机版
解决时间 2021-11-27 17:59
  • 提问者网友:太高姿态
  • 2021-11-27 00:32
cocos2d-x 如何指定Sprite 抖动效果!
最佳答案
  • 五星知识达人网友:夜余生
  • 2021-11-27 01:32
实现抖动的代码如下:
#ifndef __SHAKE_H__
#define __SHAKE_H__
#include "cocos2d.h"
USING_NS_CC;

class CCShake : public cocos2d::CCActionInterval
{
public:
CCShake();
// Create the action with a time and a strength (same in x and y)
static CCShake *create(float d, float strength );
// Create the action with a time and strengths (different in x and y)
static CCShake *createWithStrength(float d, float strength_x, float strength_y );
bool initWithDuration(float d, float strength_x, float strength_y );
protected:
void startWithTarget(cocos2d::CCNode *pTarget);
void update(float time);
void stop(void);
CCPoint m_StartPosition;
// Strength of the action
float m_strength_x, m_strength_y;
};
#endif //__SHAKE_H__
全部回答
  • 1楼网友:怙棘
  • 2021-11-27 02:50
让Sprite 无限次的执行Rotation动画,就可以实现抖动效果了。
希望能帮助到你。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯