新增跟随相机

This commit is contained in:
YHH
2020-06-19 09:16:49 +08:00
parent b83b1a5b21
commit 981e149ca5
14 changed files with 509 additions and 31 deletions

View File

@@ -22,8 +22,8 @@ class PlayerController extends Component {
if (this.down){
let camera = SceneManager.getActiveScene().camera;
let worldVec = camera.screenToWorldPoint(this.touchPoint);
console.log(worldVec, camera.transform.position);
camera.transform.position = Vector2.lerp(camera.transform.position, worldVec, Time.deltaTime);
this.entity.position = Vector2.lerp(this.entity.position, Vector2.add(worldVec,
new Vector2(this.entity.scene.stage.stageWidth / 2, this.entity.scene.stage.stageHeight / 2)), Time.deltaTime);
}
}
}