60 lines
1.1 KiB
JavaScript
60 lines
1.1 KiB
JavaScript
const ItemBase = require("nx.fx.sv.expand.item");
|
|
const HeroController = require("hero_controller");
|
|
|
|
|
|
cc.Class({
|
|
extends: ItemBase,
|
|
|
|
properties: {
|
|
tag:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
focusNd:{
|
|
default:null,
|
|
type:cc.Node
|
|
},
|
|
fabItem:{
|
|
default:null,
|
|
type:cc.Prefab
|
|
}
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
rebind(_index,_data,_key){
|
|
|
|
this._super(_index,_data,_key);
|
|
this.setData(_data);
|
|
},
|
|
|
|
setData: function( data ){
|
|
|
|
if( nx.dt.objEmpty( data ))return;
|
|
let hero = data.partner_id;
|
|
if(!this.hero){
|
|
this.hero = cc.instantiate(this.fabItem);
|
|
this.hero.parent = this.tag;
|
|
}
|
|
|
|
let cmp = nx.gui.getComponent(this.hero,"","cmp.item.base");
|
|
if(hero && cmp){
|
|
cmp.rebind( this.index, hero, "" );
|
|
}
|
|
},
|
|
|
|
onFocus(){
|
|
if(this.focusNd){
|
|
this.focusNd.active = true;
|
|
}
|
|
},
|
|
|
|
outFocus(){
|
|
if(this.focusNd){
|
|
this.focusNd.active = false;
|
|
}
|
|
}
|
|
|
|
// update (dt) {},
|
|
});
|