Files

91 lines
2.1 KiB
JavaScript
Raw Permalink Normal View History

2026-05-24 10:21:26 +08:00
"use strict";
cc._RF.push(module, '40d8dAChXtIwbMPhKFfDbYS', 'cmp.monopoly.role');
// Scripts/mod/sgames/monopoly/cmp.monopoly.role.js
"use strict";
/******************************************************************
*
* 大富翁角色
*
******************************************************************/
var FxSpine = require("nx.fx.spine");
var ACTION_WALK = "float";
var ACTION_IDLE = "stand2";
var DEF_MODEL = "H30072";
cc.Class({
"extends": cc.Component,
properties: {
spAnim: {
"default": null,
type: FxSpine
}
},
// 设定角色
setModel: function setModel(_model, _cb) {
var _this = this;
this.points = [];
this.cbEvent = _cb;
var model = _model || DEF_MODEL;
var path = PathTool.getSpinePath(model, model, false);
this.spAnim.load(path, function (_e) {
if (!_e) {
_this.spAnim.action(ACTION_IDLE, true);
}
});
},
// 设置位置
setPosition: function setPosition(_pos) {
cc.Tween.stopAllByTarget(this);
this.node.position(_pos);
this.points = [];
},
// 移动路径
pushPaths: function pushPaths(_pts, _reset) {
if (_reset === void 0) {
_reset = true;
}
// 空路径
if (nx.dt.arrEmpty(_pts)) {
return;
}
if (_reset) {
this.cur = null;
this.points = [];
cc.Tween.stopAllByTarget(this.node);
}
this.points = this.points.concat(_pts);
// 下一步
this.toNext();
},
// 下一步
toNext: function toNext() {
var _this2 = this;
// 到底
if (nx.dt.arrEmpty(this.points)) {
nx.dt.fnInvoke(this.cbEvent, "end");
this.spAnim.action(ACTION_IDLE, true);
return;
}
// 开始
if (!this.cur) {
nx.dt.fnInvoke(this.cbEvent, "start");
}
this.spAnim.action(ACTION_WALK, true);
this.cur = this.points.shift();
cc.tween(this.node).to(0.5, {
position: this.cur
}).call(function () {
_this2.toNext();
}).start();
// 方向调整
var pos = this.node.position;
this.spAnim.node.scaleX = this.cur.x < pos.x ? -1 : 1;
}
});
cc._RF.pop();