96 lines
2.3 KiB
JavaScript
96 lines
2.3 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '14002bmbVFP97z/8UzGF657', 'cmp.hoverd.wnd');
|
|
// Scripts/mod/mainui/cmp/cmp.hoverd.wnd.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
* Copyright(C) 2019 - 2020 Nx Studio
|
|
*
|
|
* 常驻悬停层
|
|
*
|
|
*
|
|
******************************************************************/
|
|
|
|
var BridgeWindow = require("bridge.window");
|
|
cc.Class({
|
|
"extends": BridgeWindow,
|
|
properties: {
|
|
nodBP: {
|
|
"default": null,
|
|
type: cc.Node
|
|
}
|
|
},
|
|
// 载入
|
|
onLoad: function onLoad() {
|
|
// 显隐
|
|
this.nodBP.active = false;
|
|
|
|
// 视图监听
|
|
this.vbind([["BPChanged", this.onBPChanged.bind(this)]]);
|
|
},
|
|
// 销毁
|
|
onDestroy: function onDestroy() {
|
|
// 视图监听解除
|
|
this.vunbind();
|
|
},
|
|
// 更新
|
|
update: function update(_dt) {
|
|
// BP更新
|
|
if (this.nodBP.active) {
|
|
// 递进
|
|
if (this.bp) {
|
|
var cur = Math.floor(this.bp.from + this.bp.step * _dt);
|
|
if (this.bp.step > 0) {
|
|
this.bp.from = Math.min(cur, this.bp.to);
|
|
} else {
|
|
this.bp.from = Math.max(cur, this.bp.to);
|
|
}
|
|
this.bp.now.string = this.bp.from.toString();
|
|
if (this.bp.from == this.bp.to) {
|
|
this.bp = null;
|
|
}
|
|
}
|
|
|
|
// 延时关闭
|
|
this.bpTime -= _dt;
|
|
if (this.bpTime <= 0) {
|
|
this.bp = null;
|
|
this.nodBP.active = false;
|
|
}
|
|
}
|
|
},
|
|
// 战力改变
|
|
onBPChanged: function onBPChanged(_cur, _old, _init) {
|
|
if (_init) {
|
|
return;
|
|
}
|
|
|
|
// 无效
|
|
if (nx.dt.arrEmpty(_cur) || _cur[0] == _cur[1]) {
|
|
return;
|
|
}
|
|
|
|
// 参数配置
|
|
this.bp = {
|
|
ofs: _cur[0],
|
|
from: _cur[1],
|
|
to: _cur[0] + _cur[1],
|
|
step: _cur[0] * 2
|
|
};
|
|
this.bp.now = nx.gui.setString(this.nodBP, "info/now", this.bp.from);
|
|
if (this.bp.ofs > 0) {
|
|
nx.gui.setActive(this.nodBP, "info/inc", true);
|
|
nx.gui.setActive(this.nodBP, "info/dec", false);
|
|
nx.gui.setString(this.nodBP, "info/inc", this.bp.ofs.toString());
|
|
} else {
|
|
nx.gui.setActive(this.nodBP, "info/inc", false);
|
|
nx.gui.setActive(this.nodBP, "info/dec", true);
|
|
nx.gui.setString(this.nodBP, "info/dec", this.bp.ofs.toString());
|
|
}
|
|
this.bpTime = 1.5;
|
|
this.nodBP.active = true;
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |