pubgv3/assets/scripts/game/horsectrl.js
zhuguoqing ff550d5d6a init
2022-05-22 10:32:02 +08:00

92 lines
2.7 KiB
JavaScript

// Learn cc.Class:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/class.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/class.html
// Learn Attribute:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/reference/attributes.html
// - [English] http://docs.cocos2d-x.org/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// - [Chinese] https://docs.cocos.com/creator/manual/zh/scripting/life-cycle-callbacks.html
// - [English] https://www.cocos2d-x.org/docs/creator/manual/en/scripting/life-cycle-callbacks.html
var gameConfig =require("gameConfig")
cc.Class({
extends: cc.Component,
properties: {
sp_head1:{
default: null,
type: cc.Sprite,
},
sp_body1:{
default: null,
type: cc.Sprite,
},
sp_neck1:{
default: null,
type: cc.Sprite,
},
sp_head2:{
default: null,
type: cc.Sprite,
},
sp_body2:{
default: null,
type: cc.Sprite,
},
sp_neck2:{
default: null,
type: cc.Sprite,
},
},
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
start () {
},
initdata(hid,play){
var horsecfg = gameConfig.dropItemConfig[hid]
var pic = horsecfg.model
if(horsecfg.equip_subtype!=1){
this.setpFrame(this.sp_head1,pic+"_head","avatar/hores")
this.setpFrame(this.sp_body1,pic+"_body","avatar/hores")
this.setpFrame(this.sp_neck1,pic+"_neck","avatar/hores")
this.setpFrame(this.sp_head2,pic+"_head_back","avatar/hores")
this.setpFrame(this.sp_body2,pic+"_body_back","avatar/hores")
this.setpFrame(this.sp_neck2,pic+"_neck_back","avatar/hores")
}
if(play){
var horseqianzui = ""
if(horsecfg.horse_anim){
var horseqianzui = horsecfg.horse_anim+"_"
}
this.node.getComponent(cc.Animation).play(horseqianzui+"horse_stand")
}
},
setpFrame(sprite,frameName,dir){
if(!sprite){
return
}
var self = this
cc.loader.loadRes(dir+"/"+frameName, cc.SpriteFrame, function (err, res) {
if (!err&&self.isValid) {
sprite.spriteFrame = res
}
});
},
// update (dt) {},
});