Hi,
I have a scene where I have the main camera “startFollow” on a player sprite with Arcade physics. I have an image sprite that relies on the scrollX and scrollY of the main camera AFTER it has finished updating to follow the player sprite.
Getting this.cameras.main.scrollX/scrollY from the update function of the scene happens before the “follow” happens, and so the image sprite lags behind in the render.
I tried using the scene “postupdate” eventEmitter.
let eventEmitter = this.scene.systems.events;
eventEmitter.on("postupdate", function() {
// Get main camera scrollX, scrollY
}, this);
The above seems to happen before the camera updates so the image sprite still lags behind.
I’ve tried adding a listener to the camera via the following:
this.cameras.main.on("postupdate", function() {
// Get the camera scrollX, and scrollY
}, this);
this.cameras.main.on("prerender", function() {
// Get the camera scrollX, and scrollY
}, this);
this.cameras.main.addListener("postupdate", function() {
// Get the camera scrollX, and scrollY
}, this);
this.cameras.main.addListener("prerender", function() {
// Get the camera scrollX, and scrollY
}, this);
But none of these seem to fire.
How can I get the scrollX and scrollY of the camera after it has finished updating because of “startFollow”?
Thanks