Files
fc/dev/project/library/imports/12/1208c777-b634-4b63-8775-860d680269a7.js
T
2026-05-24 10:21:26 +08:00

130 lines
4.0 KiB
JavaScript

"use strict";
cc._RF.push(module, '1208cd3tjRLY4d1hg1oAmmn', 'cmp.partner.look');
// Scripts/mod/partner/cmps/basic/cmp.partner.look.js
"use strict";
var BridgeWindow = require("bridge.window");
var SliderProgress = require("cmp.slider.prog.selector");
var Slider = require("cmp.slider.prog.selector");
var NxSpine = require("nx.fx.spine");
cc.Class({
"extends": BridgeWindow,
properties: {
cmpCounter: {
"default": null,
type: Slider
},
nodResult: {
"default": null,
type: NxSpine
}
},
// 重载:参数打开
onOpenConfigs: function onOpenConfigs(_params) {
this.max_scale = 1.5;
this.min_scale = 0.5;
this.nodResult.stop();
this.can = true;
// // 重建
this.setIcon(_params);
this.freshCount();
this.nodResult.node.on(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
this.nodResult.node.on(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
},
onPreClosed: function onPreClosed(_params) {
this.nodResult.node.off(cc.Node.EventType.TOUCH_MOVE, this._onTouchMove, this);
this.nodResult.node.off(cc.Node.EventType.TOUCH_END, this._onTouchEnd, this);
},
setIcon: function setIcon(_partner) {
var _this = this;
var path = "";
var cfg = game.configs.partner_data.data_partner_base[_partner.bid].draw_res;
if (cfg) {
// console.log( "当前的伙伴id" + cfg );
// 战斗迷你
path = PathTool.getSpinePath(cfg, "show", false);
this.nodResult.load(path, function (_e) {
if (!_e) {
_this.nodResult.action("action1", true);
} else {
_this.nodResult.stop();
}
});
}
},
freshCount: function freshCount() {
this.changeCount();
},
// 数量改变
changeCount: function changeCount() {
var _this2 = this;
this.maxLen = 101;
this.minLen = 1;
// 设置滚动条
this.cmpCounter.build(1, 101, 50, function (_count) {
_this2.changeScale(_count);
});
},
changeScale: function changeScale(_count) {
// _count = _count * ( ( this.max_scale - this.min_scale ) / ( this.maxLen - this.minLen ) )
// 0.1 * 5 0.1 * 10 count = 0 - 100 101 = 1 50-- 0.5 1 --- 0.1
var scale = 0;
var dec = this.maxLen - this.minLen;
var rate = (this.max_scale - this.min_scale) / dec; // 计算比率 最大减去最小
// 计算滑动条值
var progress = _count * rate + +this.min_scale;
// 当滑动条数值为 最小时 显示的当前ui的缩放比例是0.1 (101 x 0.01)x + y = 1 (50 X 0.01)x + y = 0.5
if (progress <= this.min_scale) {
scale = this.min_scale;
} else {
if (progress >= this.max_scale) {
scale = this.max_scale;
} else {
scale = progress;
}
}
// scale = _count;
// console.log( progress + "数值缩放 " + scale );
this.nodResult.node.scale = scale * 1;
},
// update (dt) {}
_onTouchMove: function _onTouchMove(touchEvent) {
// let location = touchEvent.getLocation();
// this.nodResult.node.position = this.nodResult.node.parent.convertToNodeSpaceAR( location ); // 确定位置
// 偏移移动
var offset = touchEvent.getDelta();
var pos = this.nodResult.position;
this.nodResult.position = cc.v2(pos.x + offset.x, pos.y + offset.y);
this.can = false;
},
_onTouchEnd: function _onTouchEnd(touchEvent) {
// 放下
this.can = true;
},
hideAllOps: function hideAllOps() {
nx.gui.setActive(this, "panel/ops", !nx.gui.find(this, "panel/ops").active);
nx.gui.setActive(this, "panel/back", !nx.gui.find(this, "panel/back").active);
},
// 点击动画
onTouchSpine: function onTouchSpine() {
var _this3 = this;
if (this.can) {
// 屏蔽频繁点击打断
if (this.nodResult.spAction != "action1") {
return;
}
// 播放 -> 常态
this.nodResult.action("action2", false, function (_event) {
if (_event == "complete") {
_this3.nodResult.action("action1", true);
}
});
}
}
});
cc._RF.pop();