Hi all, here’s my code I run in the update()
function of my ScrollableScene
class.
camera
is a reference to this.cameras.main
and scrollFactor
is an integer.
if (this.leftMove) {
this.camera.scrollX += (2 * this.scrollFactor)
}
else if (this.rightMove)
{
this.camera.scrollX -= (2 * this.scrollFactor);
}
I have two buttons that turn leftMove
and rightMove
on and off when we click / stop clicking.
This works pretty well, although I know that there’s probably a better way to set up the code.
I primarily develop in Firefox, so this was working fine, until I tested in Chrome, where (seemingly randomly) the scrolling will completely stutter / be choppy. Can’t really identify what interactions cause it. Anyone deal with something similar / have any tips? First project in Phaser
EDIT: More information - here’s some code that is run on create()
that might be relevant (?)
this.camera = this.cameras.main;
this.camera.fadeIn(1000);
this.bg = this.add.image(0,0,this.bgKey);
this.bg.setOrigin();
this.bg.setScrollFactor(1);
this.camera.setBounds(0, 0, this.bg.width, this.bg.height);