ChangeJobSuccess.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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, actorInfo, jobItem, upgradeLevelName, callback) {
  23. this.callback = callback;
  24. let beforType = '';
  25. for (var i = 0; i < jobData.length; i++) {
  26. if (jobData[i].id == actorInfo.jobId) {
  27. beforType = jobData[i].name;
  28. }
  29. }
  30. this.typeBeforText.string = this.outlineString(beforType, '#ffffff');
  31. this.typeAfterText.string = this.outlineString(jobItem.name, '#ffffff');
  32. this.levelNumBeforText.string = this.outlineString(actorInfo.jobLevel, '#584A47');
  33. this.levelNumAfterText.string = this.outlineString(actorInfo.jobLevel, '#584A47');
  34. this.levelNameBeforText.string = this.outlineString(actorInfo.jobLevelName, '#ffffff');
  35. this.levelNameAfterText.string = this.outlineString(upgradeLevelName, '#ffffff');
  36. this.node.parent = parent;
  37. this.content.scaleX = 0;
  38. this.content.scaleY = 0;
  39. this.scheduleOnce(() => {
  40. this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
  41. }, 0.1);
  42. },
  43. close() {
  44. let cb = this.callback
  45. let finish = cc.callFunc(() => {
  46. cb && cb();
  47. this.node.destroy();
  48. }, this);
  49. let sq = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
  50. this.content.runAction(sq);
  51. },
  52. outlineString(text, color) {
  53. return '<outline color=' + color + ' width=2><b>' + text + '</b></outline>';
  54. },
  55. onDestory() {
  56. this.confirmNode.off(cc.Node.EventType.TOUCH_END, this);
  57. }
  58. });