ChangeJobSuccess.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. var jobData = require('../data/job');
  2. cc.Class({
  3. extends: cc.Component,
  4. properties: {
  5. content: cc.Node,
  6. typeBeforSprite: cc.Sprite,
  7. typeBeforText: cc.RichText,
  8. typeAfterSprite: cc.Sprite,
  9. typeAfterText: cc.RichText,
  10. levelNumBeforText: cc.RichText,
  11. levelNumAfterText: cc.RichText,
  12. levelNameBeforText: cc.RichText,
  13. levelNameAfterText: cc.RichText,
  14. confirmNode: cc.Node,
  15. confirmText: cc.Node,
  16. },
  17. onLoad() {
  18. this.confirmNode.on(cc.Node.EventType.TOUCH_END, () => {
  19. this.close();
  20. });
  21. },
  22. show(parent, lastJob, targetJob, callback) {
  23. this.callback = callback;
  24. this.typeBeforText.string = this.outlineString(lastJob, '#ffffff');
  25. this.typeAfterText.string = this.outlineString(targetJob, '#ffffff');
  26. // this.levelNumBeforText.string = this.outlineString(actorInfo.jobLevel, '#584A47');
  27. // this.levelNumAfterText.string = this.outlineString(actorInfo.jobLevel, '#584A47');
  28. // this.levelNameBeforText.string = this.outlineString(actorInfo.jobLevelName, '#ffffff');
  29. // this.levelNameAfterText.string = this.outlineString(upgradeLevelName, '#ffffff');
  30. this.node.parent = parent;
  31. this.content.scaleX = 0;
  32. this.content.scaleY = 0;
  33. this.scheduleOnce(() => {
  34. this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
  35. }, 0.1);
  36. },
  37. close() {
  38. let cb = this.callback
  39. let finish = cc.callFunc(() => {
  40. cb && cb();
  41. this.node.destroy();
  42. }, this);
  43. let sq = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
  44. this.content.runAction(sq);
  45. },
  46. outlineString(job, color) {
  47. let icon = 50000 + job.id;
  48. return `<img src='${icon}'/> <outline color=${color} width=2><b>${job.name}</b></outline>`;
  49. },
  50. onDestory() {
  51. this.confirmNode.off(cc.Node.EventType.TOUCH_END, this);
  52. }
  53. });