修复Vector2.zero引起的引用混乱问题
This commit is contained in:
@@ -2,14 +2,12 @@ module samples {
|
||||
import CircleCollider = es.CircleCollider;
|
||||
import Flags = es.Flags;
|
||||
import SpriteRenderer = es.SpriteRenderer;
|
||||
import ProjectileHitDetector = es.ProjectileHitDetector;
|
||||
import FollowCamera = es.FollowCamera;
|
||||
|
||||
export class NinjaAdventureScene extends SampleScene {
|
||||
constructor() {
|
||||
super(true, true);
|
||||
}
|
||||
|
||||
public initialize(): void {
|
||||
super.initialize();
|
||||
public async onStart() {
|
||||
super.onStart();
|
||||
|
||||
let playerEntity = this.createEntity("player");
|
||||
playerEntity.position = new es.Vector2(256, 224);
|
||||
@@ -21,12 +19,22 @@ module samples {
|
||||
// 移动到第1层 保证自己的图层不会如果增加攻击方式则不会攻击到自身
|
||||
Flags.setFlagExclusive(collider.physicsLayer, 1);
|
||||
|
||||
this.camera.entity.addComponent(new FollowCamera(playerEntity));
|
||||
|
||||
this.content.loadRes("moon_png").then(moonTexture => {
|
||||
let moonEntity = this.createEntity("moon");
|
||||
moonEntity.position = new es.Vector2(412, 460);
|
||||
moonEntity.addComponent(new SpriteRenderer(moonTexture));
|
||||
moonEntity.addComponent(new ProjectileHitDetector());
|
||||
moonEntity.addComponent(new CircleCollider());
|
||||
});
|
||||
}
|
||||
|
||||
public update(){
|
||||
super.update();
|
||||
|
||||
this.findEntity("player").position.x -= es.Time.deltaTime * 10;
|
||||
this.findEntity("player").position.y -= es.Time.deltaTime * 10;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user