123 lines
3.9 KiB
JavaScript
123 lines
3.9 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: {
|
|
nd_front: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
nd_back: {
|
|
default: null,
|
|
type: cc.Node,
|
|
},
|
|
anibody: {
|
|
default: null,
|
|
type: cc.Animation,
|
|
},
|
|
anishoot: {
|
|
default: null,
|
|
type: cc.Animation,
|
|
},
|
|
|
|
|
|
sp_cloth_front: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
sp_hair_front: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
sp_hat_front: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
|
|
|
|
sp_cloth_back: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
sp_hair_back: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
sp_hat_back: {
|
|
default: null,
|
|
type: cc.Sprite,
|
|
},
|
|
aniweapon: {
|
|
default: null,
|
|
type: cc.Animation,
|
|
},
|
|
ani_dash_time:0.35,
|
|
aniname: ""
|
|
},
|
|
|
|
// LIFE-CYCLE CALLBACKS:
|
|
|
|
// onLoad () {},
|
|
|
|
start() {
|
|
|
|
},
|
|
|
|
|
|
|
|
initdata(target) {
|
|
|
|
// this.sp_cloth_front.spriteFrame = target.sp_cloth_front.spriteFrame
|
|
// this.sp_hair_front.spriteFrame = target.sp_hair_front.spriteFrame
|
|
// this.sp_hat_front.spriteFrame = target.sp_hat_front.spriteFrame
|
|
// this.sp_cloth_back.spriteFrame = target.sp_cloth_back.spriteFrame
|
|
// this.sp_hair_back.spriteFrame = target.sp_hair_back.spriteFrame
|
|
// this.sp_hat_back.spriteFrame = target.sp_hat_back.spriteFrame
|
|
|
|
|
|
|
|
if (target.skinarr[0] > 0) {
|
|
target.setpFrame(this.sp_hair_front, "hair_" + target.skinarr[0] + "_front", "avatar/hair")
|
|
target.setpFrame(this.sp_hair_back, "hair_" + target.skinarr[0] + "_back", "avatar/hair")
|
|
} else {
|
|
this.sp_hair_front.spriteFrame = null
|
|
this.sp_hair_back.spriteFrame = null
|
|
}
|
|
|
|
if (target.skinarr[1] > 0 && gameConfig.dropItemConfig[target.skinarr[1]]) {
|
|
var res = gameConfig.dropItemConfig[target.skinarr[1]].world_img
|
|
target.setpFrame(this.sp_cloth_front, res + "_front", "avatar/cloth")
|
|
target.setpFrame(this.sp_cloth_back, res + "_back", "avatar/cloth")
|
|
|
|
} else {
|
|
this.sp_cloth_front.spriteFrame = null
|
|
this.sp_cloth_back.spriteFrame = null
|
|
}
|
|
|
|
|
|
if (target.skinarr[2] > 0 && gameConfig.dropItemConfig[target.skinarr[2]]) {
|
|
var res = gameConfig.dropItemConfig[target.skinarr[2]].world_img
|
|
target.setpFrame(this.sp_hat_front, res + "_front", "avatar/hat")
|
|
target.setpFrame(this.sp_hat_back, res + "_back", "avatar/hat")
|
|
|
|
} else {
|
|
this.sp_hat_front.spriteFrame = null
|
|
this.sp_hat_back.spriteFrame = null
|
|
}
|
|
|
|
|
|
this.sp_hat_front.node.zIndex = target.sp_hat_front.node.zIndex
|
|
this.sp_hair_front.node.color = target.sp_hair_front.node.color
|
|
this.sp_hair_back.node.color = target.sp_hair_front.node.color
|
|
}
|
|
// update (dt) {},
|
|
}); |