{"id":6137,"date":"2024-08-18T17:01:03","date_gmt":"2024-08-18T09:01:03","guid":{"rendered":""},"modified":"2024-08-18T17:01:03","modified_gmt":"2024-08-18T09:01:03","slug":"faspeed\u662f\u4ec0\u4e48\u610f\u601d_COCOS\u5b66\u4e60\u7b14\u8bb0--\u53d8\u901f\u52a8\u4f5cSpeed\u548cActionEase","status":"publish","type":"post","link":"https:\/\/mushiming.com\/6137.html","title":{"rendered":"faspeed\u662f\u4ec0\u4e48\u610f\u601d_COCOS\u5b66\u4e60\u7b14\u8bb0--\u53d8\u901f\u52a8\u4f5cSpeed\u548cActionEase"},"content":{"rendered":"
\n

\u53d8\u901f\u52a8\u4f5c\u548c\u590d\u5408\u52a8\u4f5c\u7c7b\u4f3c\u3002\u4e5f\u662f\u4e00\u79cd\u7279\u6b8a\u7684\u52a8\u4f5c\uff0c\u5b83\u80fd\u591f\u628a\u4e0d\u8bba\u4ec0\u4e48\u52a8\u4f5c\u4f9d\u7167\u6539\u53d8\u540e\u7684\u901f\u5ea6\u8fd0\u884c\u3002\u53d8\u901f\u52a8\u4f5c\u4e0e\u590d\u5408\u52a8\u4f5c\u6700\u5927\u7684\u5dee\u522b\u5c31\u662f\u590d\u5408\u52a8\u4f5c\u4ec5\u4ec5\u662f\u5355\u7eaf\u7684\u7ec4\u5408\u4e00\u7cfb\u5217\u52a8\u4f5c\uff0c\u800c\u53d8\u901f\u7684\u505a\u5728\u7ec4\u5408\u4e00\u7cfb\u5217\u52a8\u4f5c\u540e\u8fd8\u8981\u53bb\u6539\u53d8\u52a8\u4f5c\u7684\u8fd0\u884c\u901f\u5ea6\u3002<\/p>\n

\u53d8\u901f\u52a8\u4f5c\u4e3b\u8981\u5206\u4e3a2\u5927\u7c7b\uff1aSpeed\u548cActionEase\u3002<\/p>\n

\u4e00.Speed<\/p>\n

\u7528\u4e8e\u7ebf\u6027\u5730\u6539\u53d8\u67d0\u4e2a\u52a8\u4f5c\u7684\u901f\u5ea6\uff0c\u4e5f\u5c31\u662f\u8bf4\u6210\u500d\u6570\u7684\u6539\u53d8\u67d0\u52a8\u4f5c\u7684\u603b\u4f53\u901f\u5ea6\u3002<\/p>\n

Speed\u76f8\u5f53\u4e8e\u4e00\u4e2a\u5305\u88c5\u5668\uff0c\u5c06\u987b\u8981\u6539\u53d8\u901f\u5ea6\u7684\u52a8\u4f5c\u5305\u88c5\u5230\u5f53\u4e2d\u3002<\/p>\n

Speed\u7c7b\u6e90\u4ee3\u7801\u80fd\u591f\u5728CCAction\u7c7b\u4e2d\u770b\u5230\uff1a<\/p>\n

class CC_DLL Speed : public Action<\/p>\n

{
\n <\/p>\n

......<\/p>\n

static Speed* create(ActionInterval* action, float speed);<\/p>\n

inline float getSpeed(void) const { return _speed; }<\/p>\n

inline void setSpeed(float speed) { _speed = speed; }<\/p>\n

......<\/p>\n

}<\/p>\n

\u80fd\u591f\u770b\u5230\u3002Speed\u7c7b\u662f\u76f4\u63a5\u7ee7\u627f\u81eaAction\u7c7b\u7684\u3002\u5176create()\u65b9\u6cd5\u63a5\u65362\u4e2a\u53c3\u6570\u3002\u7b2c\u4e00\u4e2a\u662f\u5176\u8981\u5305\u88c5\u7684\u52a8\u4f5c\u3002\u5fc5\u987b\u662fActionInterval\u7c7b\u578b\u7684\u52a8\u4f5c\uff0c\u5373\u7b80\u5355\u7684\u6301\u7eed\u52a8\u4f5c\u6216\u590d\u5408\u52a8\u4f5c\uff0c\u4e0d\u80fd\u591f\u662f\u5373\u65f6\u52a8\u4f5c\u3002\u7b2c\u4e8c\u4e2a\u53c3\u6570\u662f\u4e00\u4e2afloat\u7c7b\u578b\u7684\u901f\u5ea6\u503cspeed\uff0c\u8fd9\u4e2aspeed\u5c31\u662f\u8be5\u65b9\u6cd5\u8981\u5305\u88c5\u7684\u52a8\u4f5c\u539f\u6765\u8fd0\u884c\u901f\u5ea6\u7684\u500d\u6570\uff0c\u6bd4\u65b9speed=0.5\u3002\u4ee3\u8868\u5305\u88c5\u540e\u901f\u5ea6\u53d8\u4e3a\u539f\u6765\u76840.5\u500d\uff0cspeed=2\u3002\u4ee3\u8868\u5305\u88c5\u540e\u901f\u5ea6\u662f\u539f\u6765\u901f\u5ea6\u76842\u500d\u3002<\/p>\n

\u4e3e\u4e2a\u6817\u5b50\uff1a<\/p>\n

\/\/\u521b\u5efa\u4e00\u4e2asprite<\/p>\n

auto sprite = Sprite::create(\"haha.jpg\");<\/p>\n

\/\/\u52a0\u5165<\/p>\n

this->addChild(sprite);<\/p>\n

\/\/\u521b\u5efaMoveTo\u52a8\u4f5c<\/p>\n

auto _moveTo = MoveTo::create(3.0,Vec2(920,320));<\/p>\n

\/\/\u521b\u5efaSpeed\u53d8\u901f\u52a8\u4f5c<\/p>\n

\/\/\u53c3\u6570\uff1a1.\u52a8\u4f5c 2.\u6240\u5305\u88c5\u52a8\u4f5c\u539f\u6765\u901f\u5ea6\u7684\u500d\u6570<\/p>\n

auto _speed = Speed::create(_moveTo,2);<\/p>\n

\/\/\u8fd0\u884c\u52a8\u4f5c<\/p>\n

sprite->runAction(_speed);<\/p>\n

\u4e8c.ActionEase<\/p>\n

Speed\u5c3d\u7ba1\u80fd\u6539\u53d8\u52a8\u4f5c\u7684\u901f\u5ea6\uff0c\u4f46\u4ec5\u4ec5\u80fd\u6309\u6bd4\u4f8b\u6539\u53d8\u901f\u5ea6\u3002ActionEase\u80fd\u591f\u5b9e\u73b0\u52a8\u4f5c\u7684\u901f\u5ea6\u7531\u5feb\u5230\u6162\u3001\u901f\u5ea6\u968f\u65f6\u95f4\u6539\u53d8\u7684\u8fd0\u52a8\u3002\u8be5\u7c7b\u5305\u62ec\u597d\u591a\u79cd\u7c7b\u7684\u7f13\u51b2\u8fd0\u52a8\uff1a\u6307\u6570\u7f13\u51b2\u3001\u6b63\u5f26\u7f13\u51b2\u3001\u5f39\u6027\u7f13\u51b2\u3001\u8df3\u8dc3\u7f13\u51b2\u548c\u56de\u9707\u7f13\u51b2\u7b49\u7b49\u3002\u6bcf\u7c7b\u7f13\u51b2\u8fd0\u52a8\u57fa\u672c\u90fd\u5305\u62ec3\u4e2a\u4e0d\u540c\u4e00\u65f6\u5019\u671f\u7684\u53d8\u6362\uff1aIn\u3001Out\u548cInOut\uff0c\u8fd93\u4e2a\u53d8\u6362\u6709\u662f\u4ec0\u4e48\u5462\uff1f\u7b80\u5355\u6765\u8bf4\u3002In\u662f\u5728\u8fd0\u52a8\u8d77\u59cb\u65f6\u52a0\u901f\u3002Out\u662f\u5728\u8fd0\u52a8\u5feb\u7ed3\u675f\u65f6\u51cf\u901f\uff0cInOut\u5305\u62ec\u4e24\u8005\u3002\u5c31\u662f\u5148\u52a0\u901f\u540e\u51cf\u901f\u3002<\/p>\n

\u6211\u4eec\u80fd\u591f\u5148\u770b\u4e00\u4e0bActionEase\u7c7b\u7684\u6e90\u4ee3\u7801\uff1a<\/p>\n

class CC_DLL ActionEase : public ActionInterval<\/p>\n

\u8fd9\u53e5\u58f0\u660e\u80fd\u591f\u770b\u5230\uff0cActionEase\u7c7b\u662f\u7ee7\u627f\u81eaActionInterval\u7c7b\uff0c\u6240\u4ee5\u5b83\u4e5f\u662f\u4e00\u79cd\u6301\u7eed\u52a8\u4f5c\u3002<\/p>\n

\u4ee5\u4e0b\u662f\u5168\u90e8\u79cd\u7c7b\u7f13\u51b2\u8fd0\u52a8\u7684\u58f0\u660e\uff1a<\/p>\n

\/\/\u6307\u6570\u7f13\u51b2<\/p>\n

class CC_DLL EaseExponentialIn : public ActionEase<\/p>\n

class CC_DLL EaseExponentialOut : public ActionEase<\/p>\n

class CC_DLL EaseExponentialInOut : public ActionEase<\/p>\n

\/\/\u6b63\u5f26\u7f13\u51b2<\/p>\n

class CC_DLL EaseSineIn : public ActionEase<\/p>\n

class CC_DLL EaseSineOut : public ActionEase<\/p>\n

class CC_DLL EaseSineInOut : public ActionEase<\/p>\n

\/\/\u5f39\u6027\u7f13\u51b2<\/p>\n

class CC_DLL EaseElastic : public ActionEase<\/p>\n

class CC_DLL EaseElasticIn : public EaseElastic<\/p>\n

class CC_DLL EaseElasticOut : public EaseElastic<\/p>\n

class CC_DLL EaseElasticInOut : public EaseElastic<\/p>\n

\/\/\u8df3\u8dc3\u7f13\u51b2<\/p>\n

class CC_DLL EaseBounce : public ActionEase<\/p>\n

class CC_DLL EaseBounceIn : public EaseBounce<\/p>\n

class CC_DLL EaseBounceOut : public EaseBounce<\/p>\n

class CC_DLL EaseBounceInOut : public EaseBounce<\/p>\n

\/\/\u56de\u9707\u7f13\u51b2<\/p>\n

class CC_DLL EaseBackIn : public ActionEase<\/p>\n

class CC_DLL EaseBackOut : public ActionEase<\/p>\n

class CC_DLL EaseBackInOut : public ActionEase<\/p>\n

\/\/\u8d1d\u585e\u5c14\u7f13\u51b2<\/p>\n

class CC_DLL EaseBezierAction : public ActionEase<\/p>\n

\/\/\u4e8c\u6b21\u7f13\u51b2<\/p>\n

class CC_DLL EaseQuadraticActionIn : public ActionEase<\/p>\n

class CC_DLL EaseQuadraticActionOut : public ActionEase<\/p>\n

class CC_DLL EaseQuadraticActionInOut : public ActionEase<\/p>\n

\/\/\u56db\u6b21\u7f13\u51b2<\/p>\n

class CC_DLL EaseQuarticActionIn : public ActionEase<\/p>\n

class CC_DLL EaseQuarticActionOut : public ActionEase<\/p>\n

class CC_DLL EaseQuarticActionInOut : public ActionEase<\/p>\n

\/\/\u4e94\u6b21\u7f13\u51b2<\/p>\n

class CC_DLL EaseQuinticActionIn : public ActionEase<\/p>\n

class CC_DLL EaseQuinticActionOut : public ActionEase<\/p>\n

class CC_DLL EaseQuinticActionInOut : public ActionEase<\/p>\n

\/\/\u5faa\u73af\u7f13\u51b2<\/p>\n

class CC_DLL EaseCircleActionIn : public ActionEase<\/p>\n

class CC_DLL EaseCircleActionOut : public ActionEase<\/p>\n

class CC_DLL EaseCircleActionInOut:public ActionEase<\/p>\n

\/\/\u7acb\u65b9\u7f13\u51b2<\/p>\n

class CC_DLL EaseCubicActionIn:public ActionEase<\/p>\n

class CC_DLL EaseCubicActionOut : public ActionEase<\/p>\n

class CC_DLL EaseCubicActionInOut : public ActionEase<\/p>\n

\u80fd\u591f\u770b\u51fa\uff0cActionEase\u7c7b\u63d0\u4f9b\u4e86\u7684\u5404\u79cd\u7f13\u51b2\u65b9\u5f0f\u7684\u5b50\u7c7b\u3002\u6bcf\u4e00\u79cd\u7f13\u51b2\u65b9\u5f0f(\u8d1d\u585e\u5c14\u7f13\u51b2\u9664\u5916)\u57fa\u672c\u90fd\u5206\u4e3aIn\u3001Out\u548cInOut\u4e09\u79cd\u4e0d\u540c\u4e00\u65f6\u5019\u671f\u7684\u53d8\u6362\u3002<\/p>\n

\u4ee5\u4e0b\u6765\u4e3e\u4e2a\u4f7f\u7528ActionEase\u7684\u6817\u5b50\uff1a<\/p>\n

\/\/\u521b\u5efa\u4e00\u4e2asprite<\/p>\n

auto sprite = Sprite::create(\"haha.jpg\");<\/p>\n

\/\/\u52a0\u5165<\/p>\n

this->addChild(sprite);<\/p>\n

\/\/\u521b\u5efaMoveTo\u52a8\u4f5c<\/p>\n

auto _moveTo = MoveTo::create(3.0,Vec2(920,320));<\/p>\n

\/\/\u521b\u5efa\u6b63\u5f26\u7f13\u51b2\u52a8\u4f5c<\/p>\n

auto _sineEase = EaseSineInOut::create(_moveTo);<\/p>\n

\/\/\u8fd0\u884c\u52a8\u4f5c<\/p>\n

sprite->runAction(_sineEase);<\/p>\n

\u5176\u5b83\u7f13\u51b2\u7c7b\u578b\u7684\u52a8\u4f5c\u7684\u7528\u6cd5\u4e5f\u90fd\u4e0e\u4e0a\u9762\u7684\u6837\u4f8b\u4e00\u6837\u3002\u4ec5\u4ec5\u662f\u51fd\u6570\u540d\u4e0d\u540c\u3002<\/p>\n

\u8bdd\u8bf4\u6211\u8bd5\u4e86\u597d\u51e0\u79cd\uff0c\u8ba4\u4e3a\u8fd9\u4e48\u591a\u79cd\u7c7b\u7684\u8fd0\u52a8\u65b9\u5f0f\u8fd8\u771f\u770b\u4e0d\u51fa\u6765\u592a\u5927\u7684\u5dee\u522b\uff0c\u53cd\u6b63\u6211\u8ba4\u4e3a\u770b\u8d77\u6765\u90fd\u51e0\u4e4e\u76f8\u540cO(\u2229_\u2229)O\u54c8\u54c8~\u3002<\/p>\n

\u4ee5\u4e0a\u3002<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"faspeed\u662f\u4ec0\u4e48\u610f\u601d_COCOS\u5b66\u4e60\u7b14\u8bb0--\u53d8\u901f\u52a8\u4f5cSpeed\u548cActionEase\u53d8\u901f\u52a8\u4f5c\u548c\u590d\u5408\u52a8\u4f5c\u7c7b\u4f3c","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6137"}],"collection":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/comments?post=6137"}],"version-history":[{"count":0,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/posts\/6137\/revisions"}],"wp:attachment":[{"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/media?parent=6137"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/categories?post=6137"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mushiming.com\/wp-json\/wp\/v2\/tags?post=6137"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}