|
@@ -23,6 +23,8 @@ export class Hero extends BattleNodeBase {
|
|
@property({ type: Node, tooltip: '枪' })
|
|
@property({ type: Node, tooltip: '枪' })
|
|
gunNode: Node = null;
|
|
gunNode: Node = null;
|
|
|
|
|
|
|
|
+ @property({ type: UITransform, tooltip: '点击框' })
|
|
|
|
+ clickBox: UITransform = null;
|
|
|
|
|
|
//所属格子 -1表示暂无
|
|
//所属格子 -1表示暂无
|
|
private _posID = -1;
|
|
private _posID = -1;
|
|
@@ -57,6 +59,8 @@ export class Hero extends BattleNodeBase {
|
|
this.attackBone = bone
|
|
this.attackBone = bone
|
|
let rot = this.attackBone.rotation
|
|
let rot = this.attackBone.rotation
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ this.clickBox.setContentSize(this.modelSpine.getComponent(UITransform).contentSize)
|
|
}
|
|
}
|
|
|
|
|
|
start() {
|
|
start() {
|
|
@@ -128,23 +132,23 @@ export class Hero extends BattleNodeBase {
|
|
// console.log("旋转角度:", rotationAngleDegrees);
|
|
// console.log("旋转角度:", rotationAngleDegrees);
|
|
if(rotationAngleDegrees<67.5 || rotationAngleDegrees > 292.5){
|
|
if(rotationAngleDegrees<67.5 || rotationAngleDegrees > 292.5){
|
|
this.attackBone.rotation = rotationAngleDegrees
|
|
this.attackBone.rotation = rotationAngleDegrees
|
|
- if(this.modelSpine.animation != "fire_0")
|
|
|
|
- this.modelSpine.setAnimation(0, 'fire_0', true);
|
|
|
|
|
|
+ if(this.modelSpine.animation != "attack_right")
|
|
|
|
+ this.modelSpine.setAnimation(0, 'attack_right', true);
|
|
}
|
|
}
|
|
else if(rotationAngleDegrees < 112.5){
|
|
else if(rotationAngleDegrees < 112.5){
|
|
this.attackBone.rotation = rotationAngleDegrees
|
|
this.attackBone.rotation = rotationAngleDegrees
|
|
- if(this.modelSpine.animation != "fire_90")
|
|
|
|
- this.modelSpine.setAnimation(0, 'fire_90', true);
|
|
|
|
|
|
+ if(this.modelSpine.animation != "attack_right")
|
|
|
|
+ this.modelSpine.setAnimation(0, 'attack_right', true);
|
|
}
|
|
}
|
|
else if(rotationAngleDegrees < 247.5){
|
|
else if(rotationAngleDegrees < 247.5){
|
|
this.attackBone.rotation = 180-rotationAngleDegrees
|
|
this.attackBone.rotation = 180-rotationAngleDegrees
|
|
- if(this.modelSpine.animation != "fire_180")
|
|
|
|
- this.modelSpine.setAnimation(0, 'fire_180', true);
|
|
|
|
|
|
+ if(this.modelSpine.animation != "attack_left")
|
|
|
|
+ this.modelSpine.setAnimation(0, 'attack_left', true);
|
|
}
|
|
}
|
|
else if(rotationAngleDegrees < 292.5){
|
|
else if(rotationAngleDegrees < 292.5){
|
|
this.attackBone.rotation = rotationAngleDegrees
|
|
this.attackBone.rotation = rotationAngleDegrees
|
|
- if(this.modelSpine.animation != "fire_270")
|
|
|
|
- this.modelSpine.setAnimation(0, 'fire_270', true);
|
|
|
|
|
|
+ if(this.modelSpine.animation != "attack_left")
|
|
|
|
+ this.modelSpine.setAnimation(0, 'attack_left', true);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -179,8 +183,8 @@ export class Hero extends BattleNodeBase {
|
|
this.gunNode.active = true;
|
|
this.gunNode.active = true;
|
|
this.attackBone.rotation = 0
|
|
this.attackBone.rotation = 0
|
|
// this._attackCallback = null;
|
|
// this._attackCallback = null;
|
|
- if(this.modelSpine.animation == "stand_0") return;
|
|
|
|
- this.modelSpine.setAnimation(0, 'stand_0', true);
|
|
|
|
|
|
+ if(this.modelSpine.animation == "stand_right") return;
|
|
|
|
+ this.modelSpine.setAnimation(0, 'stand_right', true);
|
|
// if(this.modelSpine.node.scale.x < 0)
|
|
// if(this.modelSpine.node.scale.x < 0)
|
|
// this.modelSpine.node.scale = new Vec3(-this.modelSpine.node.scale.x,this.modelSpine.node.scale.y,this.modelSpine.node.scale.z);
|
|
// this.modelSpine.node.scale = new Vec3(-this.modelSpine.node.scale.x,this.modelSpine.node.scale.y,this.modelSpine.node.scale.z);
|
|
|
|
|
|
@@ -233,7 +237,7 @@ export class Hero extends BattleNodeBase {
|
|
}
|
|
}
|
|
|
|
|
|
hitTest(pos:Vec2){
|
|
hitTest(pos:Vec2){
|
|
- return this.modelSpine.getComponent(UITransform).hitTest(pos);
|
|
|
|
|
|
+ return this.clickBox.hitTest(pos);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|