81 lines
1.7 KiB
JavaScript
81 lines
1.7 KiB
JavaScript
"use strict";
|
|
cc._RF.push(module, '3db4bofHkdIQJTjAynmBTBu', 'cmp.bedroom.girl.show');
|
|
// Scripts/mod/home/bedroom/cmp.bedroom.girl.show.js
|
|
|
|
"use strict";
|
|
|
|
/******************************************************************
|
|
*
|
|
* 卧室角色展示
|
|
*
|
|
******************************************************************/
|
|
|
|
var FxSpine = require("nx.fx.spine");
|
|
|
|
// 部位动画配置
|
|
var IDLE = "action";
|
|
cc.Class({
|
|
"extends": cc.Component,
|
|
properties: {
|
|
spAnim: {
|
|
"default": null,
|
|
type: FxSpine
|
|
},
|
|
auVoices: {
|
|
"default": [],
|
|
type: cc.AudioClip
|
|
}
|
|
},
|
|
// 显示
|
|
onEnable: function onEnable() {
|
|
// 播放待机动画
|
|
this.partName = "";
|
|
this.spAnim.action(IDLE, true);
|
|
},
|
|
// 回调绑定
|
|
bindTouch: function bindTouch(_cb) {
|
|
this.cbTouch = _cb;
|
|
},
|
|
// 设置动作集
|
|
setActions: function setActions(_acts) {
|
|
this.actions = _acts;
|
|
},
|
|
// 播放动作
|
|
doAction: function doAction(_act) {
|
|
this.onTouchPart(_act || IDLE);
|
|
},
|
|
// 点击部位
|
|
onTouchPart: function onTouchPart(_akey) {
|
|
var _this = this;
|
|
// 正在播放
|
|
if (this.current) {
|
|
return;
|
|
}
|
|
|
|
// 未解锁动作
|
|
var info = this.actions ? this.actions[_akey] : null;
|
|
if (!info) {
|
|
nx.tbox("动作未解锁");
|
|
return;
|
|
}
|
|
|
|
// 播放动作
|
|
this.current = info;
|
|
this.spAnim.action(this.current.action, false, function (_event) {
|
|
if (_event == "complete") {
|
|
_this.current = null;
|
|
_this.spAnim.action(IDLE, true);
|
|
return;
|
|
}
|
|
});
|
|
|
|
// 播放音效
|
|
var clip = this.auVoices[this.current.voice];
|
|
if (clip) {
|
|
nx.audio.playVoice(clip);
|
|
}
|
|
nx.dt.fnInvoke(this.cbTouch, _akey);
|
|
}
|
|
});
|
|
|
|
cc._RF.pop(); |