As per title. I’m still pretty new to Phaser but have been using it fairly heavily for 6 months or so now. Still, I may have overlooked this feature.
There is an interface called
ScrollFactor whose implementors can specify to what extent they are affected by camera translation; calling
setScrollFactor(0) allows objects to ignore translation altogether and effectively remain in a static position relative to the viewport - highly useful for things like HUD elements. I was wondering if there was a similar interface (or some other way to effectively do the same thing) for a camera’s rotation as well.
No, you would probably use a separate camera for that.
Thanks for the reply!
So if I’m understanding correctly… would you stack these cameras such that a second, higher-depth camera is positioned above the first, such that the second camera “looks at” the UI elements, and then the first camera (the one which is rotated) “looks at” the rest of the scene? I’m not too familiar with using multiple cameras.
Yes, and you would also use each camera’s
ignore() method to split game objects between the two cameras.
Or put game objects at another scene, to prevent camera’s ignore for other game objects.
Oh cool, thanks for those suggestions. I’ve been playing around with the
camera.ignore() method. One thing I’ve noticed is that it seems like if I put a camera on a gameObject’s
cameraFilter list by doing, say,
myCamera.ignore(gameObject), and then later if I try and take it off again, say by doing
gameObject.cameraFilter = (gameObject.cameraFilter & ~this.hudCamera.id) | this.cameras.main.id
the object remains invisible to the second camera, even though when I print out the cameraFilter mask it seems to be correct. (In this case it shows ‘1’, so in theory it should be invisible to the main camera and visible to the second camera, if I understand correctly).
gameObject.cameraFilter = 0, it still never shows up again.
Does setting the cameraFilter field like this actually work, or does it not actually have an effect?
EDIT: never mind, the issue was on my end, I was attempting to alter the object prior to calling
this.add.existing() on it, and it seems like the changes weren’t being saved. I set the cameraFilter on the object returned by
add.existing() instead and it seems to work.