UseSkill2Efc.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. const GameNotificationKey = require('../utils/GameEnum').GameNotificationKey;
  2. const GameModule = require("../utils/GameModule");
  3. cc.Class({
  4. extends: cc.Component,
  5. properties: {
  6. coinRichText: cc.RichText,
  7. coinSkeleton: sp.Skeleton
  8. },
  9. // LIFE-CYCLE CALLBACKS:
  10. onLoad () {
  11. this.vsize = cc.view.getVisibleSize();
  12. this.coinSkeleton.node.y = -600;
  13. },
  14. init(gold) {
  15. this.gold = gold;
  16. this.showCoin();
  17. },
  18. showCoin() {
  19. let coinY = (this.vsize.height - this.coinSkeleton.node.height)/2 - 350;
  20. let moveAction = cc.moveTo(0.8, 0, coinY).easing(cc.easeCubicActionOut());
  21. let scaleAction = cc.scaleTo(0.8, 1.5, 1.5);
  22. let spaw = cc.spawn(moveAction,scaleAction);
  23. let finished = cc.callFunc(() => {
  24. this.coinSkeleton.node.scale = 1.0;
  25. this.coinSkeleton.setAnimation(0, 'jinbi_hit', false);
  26. GameModule.audioMng.playUpdateBuilding();
  27. this.coinSkeleton.setCompleteListener(() => {
  28. });
  29. setTimeout(() => {
  30. this.showCoinText();
  31. }, 700);
  32. });
  33. this.coinSkeleton.node.runAction(cc.sequence(spaw, finished));
  34. GameEvent.fire(GameNotificationKey.PlaySuccessAnimation, true);
  35. GameEvent.fire('just_cat_hit');
  36. },
  37. showCoinText() {
  38. this.coinRichText.node.active = true;
  39. this.coinRichText.string = `<img src='coin_small'/><b> +${this.gold}</>`;
  40. setTimeout(() => {
  41. this.node.destroy();
  42. }, 1100);
  43. },
  44. start () {
  45. },
  46. // update (dt) {},
  47. });