123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990 |
- cc.Class({
- extends: cc.Component,
- properties: {
- cityPic: cc.Sprite,
- incomeSpeedLabel: cc.Label,
- indexLabel: cc.Label,
- stateSprite: cc.Sprite,
- incomeLayout: cc.Node,
- },
- // onLoad () {},
- init(info, incomeSpeed) {
- this.info = info;
- this.indexLabel.string = info.id;
- this.indexLabel.node.active = true;
- if (info.selected) {
- this.statePath = 'selected';
- this.picPath = info.picId + '_';
- } else if (info.unlock) {
- this.statePath = 'unlocked';
- this.picPath = info.picId + '_';
- } else {
- this.statePath = 'lock';
- this.picPath = info.picId;
- this.indexLabel.node.active = false;
- }
- console.log('picPath: ', this.picPath);
- cc.loader.loadRes('./map/' + this.picPath, cc.SpriteFrame, (err, spriteFrame) => {
- this.cityPic.spriteFrame = spriteFrame;
- });
- cc.loader.loadRes('./map/' + this.statePath, cc.SpriteFrame, (err, spriteFrame) => {
- this.stateSprite.spriteFrame = spriteFrame;
- });
- if (incomeSpeed > 0) {
- this.incomeLayout.active = true;
- this.incomeSpeedLabel.string = `${incomeSpeed}/天`;
- } else {
- this.incomeLayout.active = false;
- }
- },
- start() {
- },
- fakeLock() {
- cc.loader.loadRes('./map/' + this.info.picId, cc.SpriteFrame, (err, spriteFrame) => {
- this.cityPic.spriteFrame = spriteFrame;
- });
- cc.loader.loadRes('./map/' + 'lock', cc.SpriteFrame, (err, spriteFrame) => {
- this.stateSprite.spriteFrame = spriteFrame;
- });
- },
- fakeUnLock() {
- cc.loader.loadRes('./map/' + this.info.unlockPicId, cc.SpriteFrame, (err, spriteFrame) => {
- this.cityPic.spriteFrame = spriteFrame;
- });
- cc.loader.loadRes('./map/' + 'unlock', cc.SpriteFrame, (err, spriteFrame) => {
- this.stateSprite.spriteFrame = spriteFrame;
- });
- },
- showFinishAnimation(cb) {
- this.cityPic.node.setScale(0);
- let end = cc.callFunc(() => {
- cb && cb();
- }, this);
- let scale = cc.sequence(cc.scaleTo(0.3, 1, 1).easing(cc.easeBackOut()), end);
- this.cityPic.node.runAction(scale);
- },
- // update (dt) {},
- });
|