JobLevelUpSuccess.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. cc.Class({
  2. extends: cc.Component,
  3. properties: {
  4. content: cc.Node,
  5. // titleText: cc.RichText,
  6. // subTitleLabel: cc.Label,
  7. levelBg: cc.Sprite,
  8. levelNumAfterText: cc.RichText,
  9. levelNameAfterText: cc.RichText,
  10. confirmNode: cc.Node,
  11. confirmText: cc.Node,
  12. levelBgFrame: [cc.SpriteFrame],
  13. },
  14. onLoad() {
  15. let self = this;
  16. this.confirmNode.on(cc.Node.EventType.TOUCH_END, () => {
  17. self.close();
  18. });
  19. },
  20. show(parent, title, subTitle, level, levelName, callback) {
  21. this.callback = callback;
  22. // this.titleText.string = this.outlineString(title, '#ffffff');
  23. // this.subTitleLabel.string = subTitle;
  24. this.levelBg.spriteFrame = this.levelBgFrame[level - 1];
  25. // this.levelNumAfterText.string = this.outlineString(level, '#584A47');
  26. this.levelNameAfterText.string = this.outlineString(levelName, '#787878');
  27. this.node.parent = parent;
  28. this.content.scaleX = 0;
  29. this.content.scaleY = 0;
  30. this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
  31. },
  32. close() {
  33. let cb = this.callback
  34. let finish = cc.callFunc(() => {
  35. cb && cb();
  36. this.node.destroy();
  37. }, this);
  38. let sq = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
  39. this.content.runAction(sq);
  40. },
  41. outlineString(text, color) {
  42. return '<outline color=' + color + ' width=2><b>' + text + '</b></outline>';
  43. },
  44. onDestory() {
  45. this.confirmNode.off(cc.Node.EventType.TOUCH_END, this);
  46. }
  47. });