AnimPlay.js 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. /**
  2. * 这个类只给PlayerAnimControl调用,其他类想调用动画去找PlayerAnimCotrol
  3. * **/
  4. cc.Class({
  5. extends: cc.Component,
  6. properties: {
  7. ArmatureDisPlay:null,
  8. },
  9. start () {
  10. },
  11. /**
  12. * @param PlayTimes
  13. *
  14. // * -1 为使用配置文件中的次数。
  15. // * 0 为无限循环播放。
  16. // * >0 为动画的重复次数。
  17. */
  18. PlayAnimationByName:function (AnimationName,PlayTimes) {
  19. // cc.log(AnimationName,'播放动画的名字');
  20. this.ArmatureDisPlay.playAnimation(AnimationName, PlayTimes);
  21. },
  22. //闲置等待动画
  23. PlayIdleAnim:function(){
  24. this.PlayAnimationByName("FemaleAwait",0);
  25. },
  26. //跑步动画。其中SpeedLevel为速度等级,范围为1-6的int型,SpeedLevel越大,速度越快
  27. PlayFemaleRunAnim:function(SpeedLevel,PlayTimes){
  28. var b = SpeedLevel-2;
  29. if(SpeedLevel==1){
  30. this.PlayAnimationByName("FemaleRun",PlayTimes);
  31. // this.ArmatureDisPlay.timeScale = 0.6;
  32. }else if(SpeedLevel==2){
  33. this.PlayAnimationByName("FemaleRunFast",PlayTimes);
  34. // this.ArmatureDisPlay.timeScale = 0.7;
  35. }else if(SpeedLevel>2 && SpeedLevel<=6){
  36. this.PlayAnimationByName("FemaleRunFast"+b,PlayTimes);
  37. // this.ArmatureDisPlay.timeScale = 0.8;
  38. }else if(SpeedLevel>6){
  39. this.PlayAnimationByName("FemaleRunFast4",PlayTimes);
  40. // this.ArmatureDisPlay.timeScale = 1;
  41. }
  42. },
  43. //跑步时摔倒动画
  44. PlayFemaleFallAnim:function(){
  45. this.PlayAnimationByName("FemaleFall1",1);
  46. },
  47. //跳远的起跳
  48. PlayLongJumpUpAnim:function(){
  49. this.PlayAnimationByName("FemaleJump",1);
  50. },
  51. //跳远的落地
  52. PlayLongJumpDownAnim:function(){
  53. this.PlayAnimationByName("FemaleDown",1);
  54. },
  55. //跨栏动作
  56. PlayHurdleJumpAnim:function(){
  57. this.PlayAnimationByName("FemaleSpan",1);
  58. },
  59. //拿着标枪跑步的动画。其中SpeedLevel为速度等级,范围为1-6的int型,SpeedLevel越大,速度越快
  60. PlayJavelinRunAnim:function(SpeedLevel,PlayTimes){
  61. if(SpeedLevel==1){
  62. this.PlayAnimationByName("FemaleJavRun",PlayTimes);
  63. }else if(SpeedLevel==2){
  64. this.PlayAnimationByName("FemaleJavFast",PlayTimes);
  65. }else if(SpeedLevel>2 && SpeedLevel<=6){
  66. var b = SpeedLevel-2;
  67. this.PlayAnimationByName("FemaleJavFast"+b,PlayTimes);
  68. }else if(SpeedLevel>6){
  69. this.PlayAnimationByName("FemaleJavFast4",PlayTimes);
  70. }
  71. },
  72. //拿标枪时摔倒
  73. PlayJavelinFallAnim:function(){
  74. this.PlayAnimationByName("FemaleJavFall1",1);
  75. },
  76. //扔出标枪动作
  77. PlayJavelinOutAnim:function(){
  78. this.PlayAnimationByName("FemaleJavOut",1);
  79. },
  80. //跳上大象的动作
  81. PlayUpElephantAnim:function(){
  82. this.PlayAnimationByName("FAnimalUp",1);
  83. },
  84. //骑大象跑的动画。其中SpeedLevel为速度等级,范围为1-6的int型,SpeedLevel越大,速度越快
  85. PlayRideElephantRunAnim:function(SpeedLevel,PlayTimes){
  86. if(SpeedLevel==1){
  87. this.PlayAnimationByName("FAnimalRun",PlayTimes);
  88. }else if(SpeedLevel==2){
  89. this.PlayAnimationByName("FAnimalRunFast",PlayTimes);
  90. }else if(SpeedLevel>2 && SpeedLevel<=6){
  91. var b = SpeedLevel-2;
  92. this.PlayAnimationByName("FAnimalRunFast"+b,PlayTimes);
  93. }else if(SpeedLevel>6){
  94. this.PlayAnimationByName("FAnimalRunFast4",PlayTimes);
  95. }
  96. },
  97. //角色跳下大象的动作
  98. PlayElephantOutAnim:function(){
  99. this.PlayAnimationByName("FAnimalOut",1);
  100. },
  101. //骑大象时踉跄
  102. PlayElephantFallAnim:function(){
  103. this.PlayAnimationByName("FAnimalFall",1);
  104. },
  105. /**
  106. * 以下动画骨骼为Jav
  107. * **/
  108. //标枪在空中飞的动作
  109. PlayJavelinFlyAnim:function(){
  110. this.PlayAnimationByName("JavFly",1);
  111. },
  112. //标枪落地的动作
  113. PlayJavelinDownAnim:function(){
  114. this.PlayAnimationByName("JavEND",1);
  115. },
  116. /**
  117. * 以下动画骨骼为Mammoth
  118. * **/
  119. //大象慢跑
  120. PlayElephantRunAnim:function () {
  121. this.PlayAnimationByName("MammothRun",0);
  122. },
  123. //动画列表,备用
  124. SetAnimationsNameArr:function(){
  125. this.AnimationsNameArr=[
  126. //跑步
  127. //0
  128. "FemaleAwait",
  129. //1
  130. "FemaleRun",
  131. // 2
  132. "FemaleRunFast",
  133. // 3
  134. "FemaleRunFast1",
  135. // 4
  136. "FemaleRunFast2",
  137. // 5
  138. "FemaleRunFast3",
  139. // 6
  140. "FemaleRunFast4",
  141. // 7
  142. "FemaleFall1",
  143. //跳远
  144. // 8
  145. "FemaleJump",
  146. // 9
  147. "FemaleDown",
  148. //跨栏
  149. // 10
  150. "FemaleSpan",
  151. //标枪
  152. // 11
  153. "FemaleJavRun",
  154. // 12
  155. "FemaleJavFast",
  156. // 13
  157. "FemaleJavFast1",
  158. // 14
  159. "FemaleJavFast2",
  160. // 15
  161. "FemaleJavFast3",
  162. // 16
  163. "FemaleJavFast4",
  164. // 17
  165. "FemaleJavOut",
  166. // 18
  167. "JavFly",
  168. // 19
  169. "JavEND",
  170. // 20
  171. "FemaleJavFall1",
  172. //骑大象
  173. // 21
  174. "FAnimalUp",
  175. // 22
  176. "MammothAwait",
  177. // 23
  178. "FAnimalRun",
  179. // 24
  180. "FAnimalRunFast",
  181. // 25
  182. "FAnimalRunFast1",
  183. // 26
  184. "FAnimalRunFast2",
  185. // 27
  186. "FAnimalRunFast3",
  187. // 28
  188. "FAnimalRunFast4",
  189. // 29
  190. "FAnimalFall",
  191. // 30
  192. "FAnimalOut",
  193. ]
  194. },
  195. });