updateCoin.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. const GameNotificationKey = require('./utils/GameEnum').GameNotificationKey;
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. updateCoinSkeletion: sp.Skeleton,
  6. },
  7. // LIFE-CYCLE CALLBACKS:
  8. onLoad () {
  9. this.updateCoinSkeletion.node.active = false;
  10. this.updateCoinSkeletion.paused = true;
  11. this.updateCoinSkeletion.setCompleteListener(() => {
  12. this.updateCoinSkeletion.node.active = false;
  13. this.updateCoinSkeletion.paused = true;
  14. });
  15. GameEvent.on(GameNotificationKey.PlayUpdateCoinAnimation, this, (position) => {
  16. let canvas = cc.find('Canvas');
  17. let canvasPosition = canvas.convertToNodeSpaceAR(position);
  18. this.updateCoinSkeletion.node.position = canvasPosition;
  19. this.updateCoinSkeletion.paused = false;
  20. this.updateCoinSkeletion.node.active = true;
  21. this.updateCoinSkeletion.setAnimation(0, 'changjing_kz');
  22. });
  23. },
  24. onDestroy() {
  25. GameEvent.off(GameNotificationKey.PlayUpdateCoinAnimation, this);
  26. },
  27. start () {
  28. },
  29. // update (dt) {},
  30. });