Charactor.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783
  1. const GameStatesStatic = require('GameStates');
  2. const PlayerState = require('PlayerState');
  3. const GameProgress = cc.Enum({
  4. default: 0,
  5. Race: 1,
  6. LongJump: 2,
  7. Hurdle: 3,
  8. RideBike: 4,
  9. Javelin: 5,
  10. });
  11. cc.Class({
  12. extends: cc.Component,
  13. properties: {
  14. readyRunTag: 0,
  15. //当前进行的项目
  16. type: 0,
  17. Canvas: {
  18. default: null,
  19. type: cc.Node
  20. },
  21. Hero: null,
  22. HeroControlScript: null,
  23. CurrentProgress: {
  24. default: GameProgress.Race,
  25. type: cc.Enum(GameProgress)
  26. },
  27. },
  28. onLoad: function () {
  29. this.Hero = this.node.parent;
  30. this.HeroControlScript = this.Hero.getComponent('HeroControl');
  31. cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
  32. },
  33. onKeyDown: function (event) {
  34. switch (event.keyCode) {
  35. case cc.KEY.a:
  36. cc.log('Press a key');
  37. this.walk();
  38. break;
  39. case cc.KEY.s:
  40. cc.log('Press a key');
  41. this.idleadd2();
  42. break;
  43. case cc.KEY.d:
  44. cc.log('Press a key');
  45. this.idle();
  46. break;
  47. }
  48. },
  49. setSkins: function (skinName) {
  50. //随机皮肤
  51. this.spine.setSkin(skinName);
  52. },
  53. start: function () {
  54. //获取 ArmatureDisplay
  55. this.spine = this.getComponent(dragonBones.ArmatureDisplay);
  56. this.arrAnimation = [];
  57. //获取 Armatrue
  58. // this.spine = this.spine.armature()
  59. //添加动画监听
  60. this.spine.addEventListener(dragonBones.EventObject.START, this.animationEventHandler, this)
  61. this.spine.addEventListener(dragonBones.EventObject.COMPLETE, this.animationEventHandler, this)
  62. var myArmature = this.spine.getArmatureNames();
  63. var myAnimationNames = this.spine.getAnimationNames(myArmature[0]);
  64. cc.log("现在 龙骨动作名字", myAnimationNames);
  65. this.initData();
  66. this.setType();
  67. this.idle();
  68. // this.walkadd();
  69. // this.idle();
  70. // this.walkadd();
  71. // this.idleadd1();
  72. return;
  73. var spine = this.spine = this.getComponent('sp.Skeleton');
  74. // cc.log("现在 播放 骨骼动画对象", spine);
  75. this._hasStop = true;
  76. this.setType();
  77. // .setStartListener()用来设置开始播放动画的事件监听。
  78. spine.setStartListener(function (trackEntry) {
  79. var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  80. // cc.log("[track %s][animation %s] start.", trackEntry.trackIndex, animationName);
  81. // cc.log("现在 播放 的动画名字是", animationName);
  82. if (animationName == this.arr[this.type][this.walkLv]) {
  83. if (this.readyRunTag == 0) {
  84. }
  85. this.readyRunTag++;
  86. // this._hasStop = false;
  87. }
  88. this.setStatus(animationName);
  89. }.bind(this));
  90. // .setInterruptListener()用来设置动画被打断的事件监听。
  91. spine.setInterruptListener(function (trackEntry) {
  92. var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  93. if (this.interruptListener != null) {
  94. this.interruptListener(animationName);
  95. }
  96. }.bind(this));
  97. // .setEndListener()用来设置动画播放完后的事件监听。
  98. spine.setEndListener(function (trackEntry) {
  99. var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  100. // cc.log("现在 停止 的动画名字是", animationName);
  101. if (animationName == this.statusArr[6] || animationName == this.statusArr[5]) {
  102. }
  103. if (this.endListener != null) {
  104. this.endListener(animationName);
  105. }
  106. }.bind(this));
  107. // .setDisposeListener()用来设置动画将被销毁的事件监听。
  108. spine.setDisposeListener(function (trackEntry) {
  109. var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  110. }.bind(this));
  111. spine.setCompleteListener(function (trackEntry, loopCount) {
  112. }.bind(this));
  113. // .setEventListener()用来设置动画播放过程中帧事件的监听。
  114. spine.setEventListener(function (trackEntry, event) {
  115. }.bind(this));
  116. },
  117. //回调
  118. animationEventHandler: function(event) {
  119. switch (event.type){
  120. case dragonBones.EventObject.START:
  121. // cc.log(this.spine.animationName , ' START complete');
  122. break;
  123. case dragonBones.EventObject.COMPLETE:
  124. // cc.log(this.spine.animationName , ' 结束的动作');
  125. // cc.log(this.spine.animationName, ' COMPLETE complete');
  126. this.complete();
  127. break;
  128. }
  129. },
  130. complete : function () {
  131. if (this.arrAnimation.length > 0) {
  132. if (this.arrAnimation.length == 1) {
  133. //如果是无限循环的
  134. if (this.arrAnimation[0].b == 0) {
  135. var arr = this.arrAnimation[0];
  136. this.arrAnimation.shift();
  137. this.addAnimation(arr);
  138. // cc.log(this.spine.animationName , ' 重复播放一个动作');
  139. }else{
  140. // cc.log(this.spine.animationName , ' 删除一个动作');
  141. this.arrAnimation.shift();
  142. return;
  143. }
  144. }else{
  145. this.arrAnimation.shift();
  146. this.delAnimation(this.arrAnimation[0]);
  147. return;
  148. }
  149. // cc.log(this.spine.animationName , ' 减少一个动作');
  150. // this.arrAnimation.shift();
  151. }
  152. if (null!=this.endListener) {
  153. this.endListener(this.spine.animationName);
  154. }
  155. },
  156. addAnimation : function (data) {
  157. this.arrAnimation.push(data);
  158. // cc.log(this.arrAnimation , ' 添加一个动作');
  159. if (this.arrAnimation.length == 1) {
  160. this.spine.playAnimation(data.name,1);
  161. }
  162. },
  163. delAnimation : function (data) {
  164. this.spine.playAnimation(data.name,1);
  165. },
  166. /**
  167. * @param name
  168. * @param b
  169. *
  170. // * -1 为使用配置文件中的次数。
  171. // * 0 为无限循环播放。
  172. // * >0 为动画的重复次数。
  173. */
  174. setAnimation : function (data) {
  175. this.arrAnimation = [];
  176. this.arrAnimation.push(data);
  177. this.spine.playAnimation(data.name,1);
  178. cc.log(this.arrAnimation , ' 设置一个动作');
  179. },
  180. initData: function () {
  181. //初始化 动作列表
  182. this.statusArr = [
  183. //0
  184. "FemaleRun",
  185. //1
  186. "FemaleAwait",
  187. // 2
  188. "FemaleRunFast",
  189. // 3
  190. "FemaleFall",
  191. // 4
  192. "FemaleJavRun",
  193. // 5
  194. "FemaleJavFast",
  195. // 6
  196. "FemaleJavFall",
  197. // 7
  198. "FemaleJavOut",
  199. // 8
  200. "FAnimalUp",
  201. // 9
  202. "FAnimalRun",
  203. // 10
  204. "FAnimalRunFast",
  205. // 11
  206. "FAnimalFall",
  207. // 12
  208. "FAnimalOut",
  209. // 13
  210. "FemaleJump",
  211. // 14
  212. "FemaleDown",
  213. // 15
  214. "FemaleSpan",
  215. // 16
  216. "FAnimalRunFast2",
  217. ];
  218. //todo 准备跑步动作
  219. this.statusArr_redyrun = [
  220. //0
  221. "FemaleAwait",
  222. ];
  223. this.arr = [];
  224. //todo 跑步动作
  225. this.statusArr_run = [
  226. //0
  227. "FemaleRun",
  228. //1
  229. "FemaleRunFast",
  230. //2
  231. "FemaleRunFast1",
  232. //3
  233. "FemaleRunFast2",
  234. //4
  235. "FemaleFall",
  236. ];
  237. this.arr.push(this.statusArr_run);
  238. //todo 跳远
  239. var a = [];
  240. this.statusArr_longjump = a.concat(this.statusArr_run);
  241. //5
  242. this.statusArr_longjump.push("FemaleJump");//这里应该是跳起落下的完整动画
  243. //6
  244. this.statusArr_longjump.push("FemaleDown");//这里应该是落下后再站起来的动画
  245. this.arr.push(this.statusArr_longjump);
  246. //todo 跨栏
  247. a = [];
  248. this.statusArr_hurdling = a.concat(this.statusArr_run);
  249. //5
  250. this.statusArr_hurdling.push("FemaleSpan");
  251. //6
  252. this.statusArr_hurdling.push("FemaleSpan");
  253. this.arr.push(this.statusArr_hurdling);
  254. //todo 蹬三轮
  255. this.statusArr_bike = [
  256. //0 跑1
  257. this.statusArr[9],
  258. //1 跑2
  259. this.statusArr[10],
  260. //2 跑3
  261. this.statusArr[16],
  262. //3 踉跄
  263. this.statusArr[11],
  264. //4 上车
  265. this.statusArr[8],
  266. //5 下车
  267. this.statusArr[12],
  268. ];
  269. this.arr.push(this.statusArr_bike);
  270. //todo 标枪项目
  271. this.statusArr_javelin = [
  272. //0 跑1
  273. this.statusArr[4],
  274. //1 跑2
  275. this.statusArr[4],
  276. //2 跑3
  277. this.statusArr[5],
  278. //3 踉跄
  279. this.statusArr[6],
  280. //4 捡标枪
  281. this.statusArr[7],
  282. //5 扔标枪
  283. this.statusArr[7],
  284. ];
  285. this.arr.push(this.statusArr_javelin);
  286. //todo 标枪
  287. this.statusArr_biaoqiang = [
  288. "Biaoqiang01",
  289. "Biaoqiang02",
  290. "Biaoqiang03",
  291. ];
  292. //初始化动作状态
  293. this.setStatus(this.statusArr[1]);
  294. this.setMyTag(null);
  295. },
  296. setMyTag: function (obj) {
  297. this.myTag = obj;
  298. },
  299. idle: function () {
  300. this.spine.timeScale = 1.0;
  301. // this.spine.setAnimation(0, this.statusArr_redyrun[0], true);
  302. var data = {
  303. name : this.statusArr_redyrun[0],
  304. b : 0
  305. }
  306. this.setAnimation(data);
  307. },
  308. idleadd: function () {
  309. var data = {
  310. name : this.statusArr_redyrun[0],
  311. b : 0
  312. }
  313. this.addAnimation(data);
  314. },
  315. idleadd1: function () {
  316. var data = {
  317. name : this.statusArr[5],
  318. b : 1
  319. }
  320. this.addAnimation(data);
  321. },
  322. idleadd2: function () {
  323. var data = {
  324. name : this.statusArr[6],
  325. b : 1
  326. }
  327. this.addAnimation(data);
  328. },
  329. addidle: function () {
  330. this.spine.setAnimation(0, this.statusArr_redyrun[0], false);
  331. },
  332. test: function () {
  333. this.spine.setAnimation(0, this.statusArr_run[2], true);
  334. },
  335. walk: function () {
  336. // .setAnimation(trackIndex,name,loop)设置当前动画。队列中的任何的动画将被清除。返回一个 sp.spine.TrackEntry 对象。
  337. var data = {
  338. name : this.statusArr[2],
  339. b : 1
  340. }
  341. this.addAnimation(data);
  342. },
  343. walkadd: function () {
  344. // .setAnimation(trackIndex,name,loop)设置当前动画。队列中的任何的动画将被清除。返回一个 sp.spine.TrackEntry 对象。
  345. var data = {
  346. name : this.statusArr[2],
  347. b : 0
  348. }
  349. this.addAnimation(data);
  350. },
  351. readyRun: function () {
  352. // this.spine.setAnimation(0, this.statusArr_redyrun[0], false);
  353. // this.spine.addAnimation(0, this.statusArr_redyrun[1], false);
  354. var data = {
  355. name : this.statusArr_run[0],
  356. b : 0
  357. }
  358. this.setAnimation(data);
  359. //奔跑等级
  360. this.walkLv = 0;
  361. },
  362. readyRun_add: function () {
  363. // this.spine.setAnimation(0, this.statusArr_redyrun[0], false);
  364. // this.spine.addAnimation(0, this.statusArr_redyrun[1], false);
  365. this.spine.addAnimation(0, this.statusArr_run[0], true);
  366. //奔跑等级
  367. this.walkLv = 0;
  368. },
  369. SetCurrentAnimationIdx: function (idx) {
  370. // this.spine.addAnimation(0, this.arr[this.type][idx], true);
  371. var data = {
  372. name : this.arr[this.type][idx],
  373. b : 0
  374. }
  375. this.addAnimation(data);
  376. },
  377. SetCurrentAnimationIdx_set: function (idx) {
  378. // this.spine.setAnimation(0, this.arr[this.type][idx], true);
  379. var data = {
  380. name : this.arr[this.type][idx],
  381. b : 0
  382. }
  383. this.setAnimation(data);
  384. },
  385. //todo 设置对应动作
  386. setCurrentSpeed: function () {
  387. this.walkLv = this.getSpeedLv();
  388. // cc.log("当前速度","档位",this.walkLv);
  389. // this.spine.addAnimation(0, this.arr[this.type][this.walkLv], true);
  390. var data = {
  391. name : this.arr[this.type][this.walkLv],
  392. b : 0
  393. }
  394. this.addAnimation(data);
  395. this.spine.timeScale = 1;
  396. },
  397. stagger: function () {
  398. // this.spine.setAnimation(0, this.arr[this.type][3], false);
  399. var data = {
  400. name : this.arr[this.type][3],
  401. b : 1
  402. }
  403. this.setAnimation(data);
  404. },
  405. longjump: function (jumpTimer) {
  406. cc.log('************longjump**********');
  407. // this.spine.timeScale = 1.5;
  408. // this.spine.setAnimation(0, this.statusArr_longjump[5], false);
  409. var data = {
  410. name: this.statusArr_longjump[5],
  411. b: 1
  412. };
  413. this.setAnimation(data);
  414. this.spine.timeScale = 1/jumpTimer;
  415. // console.log("timeScale ==", jumpTimer, this.spine.timeScale);
  416. var OutTimer = jumpTimer* 1000 + 300;
  417. // console.log("jumpTimer ==", jumpTimer, OutTimer);
  418. setTimeout(function () {
  419. cc.log('************longjump*****timeout*****');
  420. if (this.timeOutLongJumpListener != null) {
  421. this.timeOutLongJumpListener();
  422. }
  423. }.bind(this), OutTimer);
  424. },
  425. setTimeOutLongJumpListener: function (timeOutLongJumpListener) {
  426. this.timeOutLongJumpListener = timeOutLongJumpListener;
  427. },
  428. longjump_stagger: function () {
  429. this.spine.setAnimation(0, this.statusArr_longjump[1], false);
  430. this.setCurrentSpeed();
  431. },
  432. hurdling: function (callBack) {
  433. var data = {
  434. name : this.statusArr_hurdling[5],
  435. b : 0
  436. }
  437. this.setAnimation(data);
  438. // this.spine.setAnimation(0, this.statusArr_hurdling[5], false);
  439. // this.spine.addAnimation(0, this.statusArr_hurdling[this.walkLv], true);
  440. this.spine.timeScale = 1.5;
  441. // if (callBack != null) {
  442. // this.spine.setInterruptListener(function (trackEntry) {
  443. // var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  444. // if ("hurdling_1" == animationName) {
  445. // callBack(animationName);
  446. // this.spine.timeScale = 1;
  447. // }
  448. // }.bind(this));
  449. //
  450. // }
  451. this.setEndListener(function (animationName) {
  452. if (animationName == this.statusArr_hurdling[5]) {
  453. if (callBack != null) {
  454. callBack(animationName);
  455. }
  456. this.spine.timeScale = 1;
  457. }
  458. }.bind(this));
  459. this.setCurrentSpeed();
  460. },
  461. hurdling_stagger: function () {
  462. this.spine.setAnimation(0, this.statusArr_hurdling[1], false);
  463. this.setCurrentSpeed();
  464. },
  465. //单纯的停止
  466. stop: function () {
  467. // .clearTrack(对应状态数字)清除出指定 track 的动画状态。
  468. this.spine.clearTrack(0);
  469. this.setStatus(this.statusArr_redyrun[0]);
  470. },
  471. //调用一次 暂停 再调用 恢复
  472. paused: function () {
  473. // .clearTrack(对应状态数字)清除出指定 track 的动画状态。
  474. if (this.spine.paused) {
  475. this.spine.paused = false;
  476. } else {
  477. this.spine.paused = true;
  478. }
  479. },
  480. /**
  481. * 设置当前的运动状态
  482. * @param status
  483. */
  484. setStatus: function (status) {
  485. this.myStatus = status;
  486. },
  487. //按屏幕了
  488. setOnTouchListener: function () {
  489. this.setType();
  490. // cc.log("当前游戏 按屏幕了", cc.find('Canvas').getComponent("GameStates").CurrentProgress);
  491. if (this.spine.animationName == this.statusArr_redyrun[0]) {
  492. // this.setCurrentSpeed();
  493. switch (this.type) {
  494. case 0:
  495. this.readyRun();
  496. break;
  497. case 3:
  498. this.BikeRun();
  499. break;
  500. }
  501. return;
  502. }
  503. },
  504. //todo 跨栏 跳跃
  505. setOnHurdlingListener: function (callBack) {
  506. this.setType();
  507. this.hurdling(callBack);
  508. },
  509. //todo 跨栏 踉跄
  510. setOnHurdlingStaggerListener: function () {
  511. this.setType();
  512. this.hurdling_stagger();
  513. },
  514. //todo 跳远跳跃
  515. setOnLongJumpListener: function (jumpTimer) {
  516. this.setType();
  517. this.longjump(jumpTimer);
  518. },
  519. //todo 跳远 踉跄
  520. setOnLongJumpStaggerListener: function () {
  521. this.setType();
  522. this.stagger();
  523. },
  524. //摔倒了
  525. setOnTripListener: function () {
  526. this.setType();
  527. this.stagger();
  528. },
  529. toggleTimeScale: function () {
  530. // .timeScale当前骨骼中所有动画的时间缩放率。
  531. if (this.spine.timeScale === 1.0) {
  532. this.spine.timeScale = 0.3;
  533. } else {
  534. this.spine.timeScale = 1.0;
  535. }
  536. },
  537. setEndListener: function (endListener) {
  538. this.endListener = endListener
  539. },
  540. endListener: function () {
  541. },
  542. setInterruptListener: function (interruptListener) {
  543. this.interruptListener = interruptListener
  544. },
  545. interruptListener: function () {
  546. },
  547. //todo 快上车 没时间解释了
  548. upBike: function () {
  549. this.setType();
  550. // this.spine.setAnimation(0, this.statusArr_bike[9], false);
  551. // this.spine.addAnimation(0, this.statusArr_bike[0], true);
  552. //
  553. var data = {
  554. name : this.statusArr_bike[4],
  555. b : 1
  556. }
  557. this.setAnimation(data);
  558. var dataadd = {
  559. name : this.statusArr_bike[0],
  560. b : 0
  561. }
  562. // cc.log('==============分割线============');
  563. cc.log(dataadd.name);
  564. this.addAnimation(dataadd);
  565. this.walkLv = 0;
  566. cc.find('Canvas').getComponent('GameStates').CurrentProgress = GameStatesStatic.GameProgress.RideBike;
  567. },
  568. BikeRun:function(){
  569. var dataadd = {
  570. name : this.statusArr_bike[0],
  571. b : 0
  572. }
  573. // cc.log('***************分割线*************');
  574. // cc.log(dataadd.name);
  575. this.setAnimation(dataadd);
  576. },
  577. //todo 快下车 没时间解释了
  578. downBike: function (callBack) {
  579. this.setType();
  580. // this.spine.setAnimation(0, this.statusArr_bike[4], false);
  581. var data = {
  582. name : this.statusArr_bike[5],
  583. b : 1
  584. }
  585. this.setAnimation(data);
  586. cc.log('设置了动画呀。');
  587. if (callBack != null) {
  588. // this.spine.setEndListener(function (trackEntry) {
  589. // var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  590. // if (animationName == this.statusArr_bike[0]) {
  591. // callBack(animationName);
  592. // }
  593. // }.bind(this));
  594. this.setEndListener(function (animationName) {
  595. if (animationName == this.statusArr_bike[5]) {
  596. callBack(animationName);
  597. }
  598. }.bind(this));
  599. }
  600. this.walkLv = 0;
  601. },
  602. //todo 快拿标枪 没时间解释了
  603. upJavelin: function () {
  604. this.setType();
  605. // this.spine.setAnimation(0, this.statusArr_javelin[1], true);
  606. var data = {
  607. name : this.statusArr_javelin[0],
  608. b : 0
  609. }
  610. this.setAnimation(data);
  611. },
  612. //todo 快扔标枪 没时间解释了
  613. upJavelin_go: function (callBack) {
  614. this.setType();
  615. // this.spine.setAnimation(0, this.statusArr_javelin[6], false);
  616. var data = {
  617. name : this.statusArr_javelin[5],
  618. b : 1
  619. }
  620. this.setAnimation(data);
  621. this.spine.timeScale = 1;
  622. // setTimeout(function () {
  623. // this.spine.timeScale = 1;
  624. // }.bind(this), 600);
  625. // this.walkLv = 0;
  626. if (callBack != null) {
  627. this.spine.setEndListener(function (trackEntry) {
  628. var animationName = trackEntry.animation ? trackEntry.animation.name : "";
  629. callBack(animationName);
  630. }.bind(this));
  631. }
  632. },
  633. //todo 快扔标枪 没时间解释了
  634. javelin: function () {
  635. this.setType();
  636. this.spine.armatureName = 'Jav';
  637. this.spine.playAnimation('JavFly', -1);
  638. // cc.log('??????????????');
  639. this.spine.setAnimation(0, this.statusArr_biaoqiang[0], false);
  640. this.spine.addAnimation(0, this.statusArr_biaoqiang[1], false);
  641. this.spine.addAnimation(0, this.statusArr_biaoqiang[2], false);
  642. },
  643. setType: function () {
  644. // return;
  645. var temp = cc.find('Canvas').getComponent("GameStates").CurrentProgress;
  646. // cc.log("现在那标枪",temp);
  647. switch (temp) {
  648. case GameStatesStatic.GameProgress.Race:
  649. this.type = 0;
  650. // cc.log("当前的typssssse","s1");
  651. break;
  652. case GameStatesStatic.GameProgress.LongJump:
  653. this.type = 1;
  654. // cc.log("当前的typssssse","s2");
  655. break;
  656. case GameStatesStatic.GameProgress.Hurdle:
  657. this.type = 2;
  658. // cc.log("当前的typssssse","s3");
  659. break;
  660. case GameStatesStatic.GameProgress.RideBike:
  661. this.type = 3;
  662. // cc.log("当前的typssssse","s4");
  663. break;
  664. case GameStatesStatic.GameProgress.Javelin:
  665. this.type = 4;
  666. // cc.log("当前的typssssse","s5");
  667. break;
  668. }
  669. },
  670. getSpeedLv: function () {
  671. var TouchLayout = cc.find("TouchLayout");
  672. // var lv = TouchLayout.getComponent("NodeTouch").Hero.getComponent("HeroControl").PlayerStateScript.CurrentSpeed;
  673. var lv = cc.find('Hero').getComponent("HeroControl").PlayerStateScript.CurrentSpeed;
  674. var state = PlayerState.SpeedRangeForAnimation;
  675. if (lv >= state.SlowSpeed[0] && lv <= state.SlowSpeed[1]) {
  676. return 0;
  677. }
  678. if (lv >= state.MiddleSpeed[0] && lv <= state.MiddleSpeed[1]) {
  679. return 1;
  680. }
  681. if (lv >= state.HightSpeed[0] && lv <= state.HightSpeed[1]) {
  682. return 2;
  683. }
  684. return 0;
  685. }
  686. });