碰撞系统重做
This commit is contained in:
@@ -45,9 +45,9 @@ export class Skill extends ecs.Entity {
|
||||
sv.angle = angle;
|
||||
sv.t_pos = t_pos;
|
||||
if(scale == 1){
|
||||
sv.change_collider_group(BoxSet.HERO_SKILL)
|
||||
sv.box_group=BoxSet.HERO_SKILL
|
||||
}else{
|
||||
sv.change_collider_group(BoxSet.MONSTER_SKILL)
|
||||
sv.box_group=BoxSet.MONSTER_SKILL
|
||||
}
|
||||
this.add(sv);
|
||||
}
|
||||
|
||||
@@ -24,15 +24,13 @@ export class SkillCom extends CCComp {
|
||||
angle:number = 0;
|
||||
t_pos:Vec3 = null;
|
||||
is_destroy:boolean = false;
|
||||
box_group:number = 0;
|
||||
start() {
|
||||
this.node.active=true
|
||||
this.node.angle = this.angle;
|
||||
//根据目标坐标、欧拉角、预设距离增量speed 来计算新的x增量,y增量
|
||||
// this.x_speed = Math.cos(this.angle * Math.PI / 180) * this.speed;
|
||||
// this.y_speed = Math.sin(this.angle * Math.PI / 180) * this.speed;
|
||||
|
||||
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = this.box_group;
|
||||
if (collider) {
|
||||
// collider.on(Contact2DType.BEGIN_CONTACT, this.onBeginContact, this);
|
||||
collider.on(Contact2DType.POST_SOLVE, this.onPostSolve, this);
|
||||
@@ -86,11 +84,7 @@ export class SkillCom extends CCComp {
|
||||
|
||||
}
|
||||
|
||||
change_collider_group(group:number){
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = group;
|
||||
}
|
||||
update(deltaTime: number) {
|
||||
update(deltaTime: number) {
|
||||
// this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||
this.move(deltaTime)
|
||||
// if(Math.abs(this.node.position.x) > this.dis)
|
||||
|
||||
@@ -41,10 +41,7 @@ export class baseCom extends Component {
|
||||
reset() {
|
||||
this.node.destroy();
|
||||
}
|
||||
change_collider_group(group:number){
|
||||
let collider = this.getComponent(Collider2D);
|
||||
collider.group = group;
|
||||
}
|
||||
|
||||
update(deltaTime: number) {
|
||||
this.node.setScale(v3(this.scale,this.node.scale.y,this.node.scale.z))
|
||||
this.node.setPosition(v3(this.node.position.x+deltaTime*this.speed*this.scale,this.node.position.y,this.node.position.z))
|
||||
|
||||
Reference in New Issue
Block a user