s4m_ur4i Posted October 20, 2018 Share Posted October 20, 2018 I am on WebGL mode, with a camera.zoom(7) and put some sprites to setScrollFactor(0) they disappear. So I had a look at the camera, in the top left corner of the game, it has a .scrollX/Y of high minus values. I already recalculated the world bounds and camera bounds, but that won't help. For me, this seems like a bug right now, but maybe I am again just missing something. I also noticed that the: this.camera.main.worldView.width // also height Is not set correctly, it is set some milliseconds after create is initiated, but if I log it directly in create it just holds the whole window width in pixels, not the zoomed calculation. Can someone else have a look at this? It's reproducible as far as I can see. Thanks in advance EDIT: as I see, this intended behavior, not a bug: setZoom( [value]) Set the zoom value of the Camera. Changing to a smaller value, such as 0.5, will cause the camera to 'zoom out'. Changing to a larger value, such as 2, will cause the camera to 'zoom in'. A value of 1 means 'no zoom' and is the default. Changing the zoom does not impact the Camera viewport in any way, it is only applied during rendering. https://photonstorm.github.io/phaser3-docs/Phaser.Cameras.Scene2D.Camera.html#setZoom__anchor But is there a way to get scrollFactor to work with a zoom? Reason: I got a camera permanently on zoom, which needs some UI displayed. Link to comment Share on other sites More sharing options...
s4m_ur4i Posted October 20, 2018 Author Share Posted October 20, 2018 After digging through the documentation: I think this is not intended behavior. At least, if you have a game were the camera zoom out and in because of multiplayer or having an action platformer, there is no way to fix any sprite to the camera's view. If a sprite is set with sprite.setScrollFactor(0) it should be kept in view when the sprite's position is initially in view. Even if the camera is zoomed.Zoom is an option on the game config, and useful in a lot of cases to have your game with a base zoom. Rather than taking the scrollX and scrollY of the camera, which are minus values by zoom > 1, setScrollFactor should align to the worldview. Or at least it would be helpful to have a value that can be set to be fixed on zoom. Because, as far as I am aware, there is nothing to calculate the offset of the current zoom right now. solution: use a second scene for UI stuff, or alignment Link to comment Share on other sites More sharing options...
Recommended Posts