12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- var jobData = require('../data/job');
- cc.Class({
- extends: cc.Component,
- properties: {
- content: cc.Node,
- typeBeforSprite: cc.Sprite,
- typeBeforText: cc.RichText,
- typeAfterSprite: cc.Sprite,
- typeAfterText: cc.RichText,
- levelNumBeforText: cc.RichText,
- levelNumAfterText: cc.RichText,
- levelNameBeforText: cc.RichText,
- levelNameAfterText: cc.RichText,
- confirmNode: cc.Node,
- confirmText: cc.Node,
- },
- onLoad() {
- this.confirmNode.on(cc.Node.EventType.TOUCH_END, () => {
- this.close();
- });
- },
- show(parent, actorInfo, jobItem, upgradeLevelName, callback) {
- this.callback = callback;
- let beforType = '';
- for (var i = 0; i < jobData.length; i++) {
- if (jobData[i].id == actorInfo.jobId) {
- beforType = jobData[i].name;
- }
- }
- this.typeBeforText.string = this.outlineString(beforType, '#ffffff');
- this.typeAfterText.string = this.outlineString(jobItem.name, '#ffffff');
- this.levelNumBeforText.string = this.outlineString(actorInfo.jobLevel, '#584A47');
- this.levelNumAfterText.string = this.outlineString(actorInfo.jobLevel, '#584A47');
- this.levelNameBeforText.string = this.outlineString(actorInfo.jobLevelName, '#ffffff');
- this.levelNameAfterText.string = this.outlineString(upgradeLevelName, '#ffffff');
- this.node.parent = parent;
- this.content.scaleX = 0;
- this.content.scaleY = 0;
- this.scheduleOnce(() => {
- this.content.runAction(cc.scaleTo(0.35, 1, 1).easing(cc.easeBackOut()));
- }, 0.1);
- },
- close() {
- let cb = this.callback
- let finish = cc.callFunc(() => {
- cb && cb();
- this.node.destroy();
- }, this);
- let sq = cc.sequence(cc.scaleTo(0.2, 0, 0).easing(cc.easeBackIn()), finish)
- this.content.runAction(sq);
- },
- outlineString(text, color) {
- return '<outline color=' + color + ' width=2><b>' + text + '</b></outline>';
- },
- onDestory() {
- this.confirmNode.off(cc.Node.EventType.TOUCH_END, this);
- }
- });
|