This commit is contained in:
2024-07-30 13:13:40 +08:00
parent d85ed9e6b6
commit 79c3a23f09
3 changed files with 12 additions and 7 deletions

View File

@@ -289,8 +289,8 @@
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",
"x": 0.53125, "x": 0.5,
"y": 0.53125 "y": 0.5
}, },
"_id": "" "_id": ""
}, },
@@ -701,8 +701,8 @@
}, },
"_contentSize": { "_contentSize": {
"__type__": "cc.Size", "__type__": "cc.Size",
"width": 100, "width": 60,
"height": 100 "height": 60
}, },
"_anchorPoint": { "_anchorPoint": {
"__type__": "cc.Vec2", "__type__": "cc.Vec2",

View File

@@ -22,7 +22,7 @@ export class Monster extends ecs.Entity {
MonsterModel!: MonsterModelComp; MonsterModel!: MonsterModelComp;
// 视图层 // 视图层
MonsterView!: MonsterViewComp; MonsterView!: MonsterViewComp;
MoveToComp!: MoveToComp; // 移动 RoleMoveTo!: MoveToComp; // 移动
protected init() { protected init() {
this.addComponents<ecs.Comp>( this.addComponents<ecs.Comp>(
@@ -46,7 +46,9 @@ export class Monster extends ecs.Entity {
node.setPosition(pos) node.setPosition(pos)
var mv = node.getComponent(MonsterViewComp)!; var mv = node.getComponent(MonsterViewComp)!;
mv.speed = speed;
mv.ospeed = speed;
mv.Tpos = v3(0,0,0);
this.add(mv); this.add(mv);
smc.monsters_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0}), smc.monsters_in.push({name:mv.ent.name,eid:mv.ent.eid,pos_x:0}),
// node.setScale(-1, 1, 1); // node.setScale(-1, 1, 1);

View File

@@ -50,6 +50,7 @@ export class MonsterViewComp extends CCComp {
this.move(dt); this.move(dt);
} }
if(this.node.position.x < -300){ if(this.node.position.x < -300){
console.log(this.node,this.ent)
smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid); smc.monsters_in = smc.monsters_in.filter(element => element.eid !== this.ent.eid);
this.node.destroy(); this.node.destroy();
} }
@@ -60,8 +61,10 @@ export class MonsterViewComp extends CCComp {
this.node.setPosition(this.node.position.x-dt*this.speed, this.node.position.y, this.node.position.z); this.node.setPosition(this.node.position.x-dt*this.speed, this.node.position.y, this.node.position.z);
} }
update_pos(){ update_pos(){
smc.monsters_in.forEach(element => { smc.monsters_in.forEach((element,index) => {
if(element.eid == this.ent.eid){ if(element.eid == this.ent.eid){
console.log("index:"+index)
element.pos_x = this.node.position.x; element.pos_x = this.node.position.x;
} }
}); });