123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172 |
- 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, lastJob, targetJob, callback) {
- this.callback = callback;
- this.typeBeforText.string = this.outlineString(lastJob, '#ffffff');
- this.typeAfterText.string = this.outlineString(targetJob, '#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(job, color) {
- let icon = 50000 + job.id;
- return `<img src='${icon}'/> <outline color=${color} width=2><b>${job.name}</b></outline>`;
- },
- onDestory() {
- this.confirmNode.off(cc.Node.EventType.TOUCH_END, this);
- }
- });
|