1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- // Learn cc.Class:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/class.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/class.html
- // Learn Attribute:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/reference/attributes.html
- // Learn life-cycle callbacks:
- // - [Chinese] http://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
- // - [English] http://www.cocos2d-x.org/docs/creator/en/scripting/life-cycle-callbacks.html
- var Module = require('Module');
- cc.Class({
- extends: cc.Component,
- properties: {
- lvLabel: {
- default: null,
- type: cc.Label
- },
- earnMoneyLabel: {
- default: null,
- type: cc.Label
- },
- costLabel: {
- default: null,
- type: cc.Label
- },
- roomSprite: {
- default: null,
- type: cc.Sprite
- },
- nameLabel: {
- default: null,
- type: cc.Label
- },
- },
- // LIFE-CYCLE CALLBACKS:
- onLoad () {},
- init(room, config, roomSpriteFrame) {
- this.room = room;
- this.lvLabel.string = "Lv" + (config.lv + 1).toString();
- this.earnMoneyLabel.string = config.speed[config.lv].toString();
- this.costLabel.string = config.price[config.lv].toString();
- this.roomSprite.spriteFrame = roomSpriteFrame;
- this.nameLabel.string = config.name;
- },
- clickCloseButton: function () {
- let callBack = cc.callFunc(function () {
- Module.game.getComponent('game').setBuyTipNode(null);
- this.node.destroy();
- }, this);
- this.closeAnimation(callBack);
- },
- clickUpdateButton: function () {
- let callBack = cc.callFunc(function () {
- this.room.getComponent('room').updateAnimation();
- Global.GameEvent.fire("room_update", this.room);
- this.node.destroy();
- }, this);
- this.closeAnimation(callBack);
- },
- closeAnimation: function (callBack) {
- if (callBack !== undefined) {
- let action = cc.scaleTo(0.2, 0, 0).easing(cc.easeOut(0.95));
- this.node.runAction(cc.sequence(action, callBack));
- }
- },
- // update (dt) {},
- });
|