I would like the camera to move to a specific offSetX. Using the method "horizontalCamera.setScroll(800,0)" it moves instantly. How can I make it move with an animation?
P.S. I’m using phaser editor 2d
class GoNext extends UserComponent {
constructor(gameObject) {
super(gameObject);
this.gameObject = gameObject;
gameObject["__GoNext"] = this;
/* START-USER-CTR-CODE */
// Write your code here.
/* END-USER-CTR-CODE */
}
/** @returns {GoNext} */
static getComponent(gameObject) {
return gameObject["__GoNext"];
}
/** @type {Phaser.GameObjects.Text} */
gameObject;
/* START-USER-CODE */
awake() {
let horizontalCamera
this.gameObject.setInteractive().on("pointerdown", () => {
horizontalCamera = this.scene.cameras.add(0, 0, 800, 600)
horizontalCamera.setScroll(800, 0)
});
}
// Write your code here.
/* END-USER-CODE */
}
3
Answers
This method was a little difficult for me.
If you want to pan to a specific position, you can use the function
pan
link to the documentationCheck out this official demo, for a usable demo.
Also, you can "tween" the camera.
Something like this: