zetsubou Posted November 28, 2018 Share Posted November 28, 2018 Hi! I have an issue with camera position accordingly to tilemap. My goal is supermario-like platformer. I create the game instance, but tilemap(that i created from JSON) is 2400 px in height, so it does not fit at the screen. Seems like i can spawn objects out of the current screen bounds, but cant reach these with camera. Cameras origin is located at the very top of the screen(0,0), however anything spawned is far beyond from it at the bottom(i tried to use a viewport, but just getting nothing changed). Can I rotate camera somehow? I tried: this.cameras.main.viewPort(window.innerWidth, window.innerHeight, 200, 1800) Also tried to focus main camera on the player(failed it either). Link to comment Share on other sites More sharing options...
samme Posted November 28, 2018 Share Posted November 28, 2018 http://labs.phaser.io/edit.html?src=src\camera\set bounds.js Link to comment Share on other sites More sharing options...
zetsubou Posted November 29, 2018 Author Share Posted November 29, 2018 14 hours ago, samme said: http://labs.phaser.io/edit.html?src=src\camera\set bounds.js Thanks! But I still cannot spawn a player outside of game bounds. It appears at the top of the screen(where game bounds are defined, i guess) no matter what coordinates I use. Perhaps, I should expand game bounds, but doesn't it affect a game performance? Link to comment Share on other sites More sharing options...
zetsubou Posted November 29, 2018 Author Share Posted November 29, 2018 Nevermind, I can, but it disappears immediately and camera flies away at the top outside of game bounds. Can't figure out why camera, if i do: this.physics.add.existing(ground); flies away even out of the game bounds(as i said above). Now it looks too confusing) UPD: I have to expand game world bounds cause nothing is drawn outside of it(what does make sense, but it seems to strongly affect performance). Link to comment Share on other sites More sharing options...
samme Posted November 29, 2018 Share Posted November 29, 2018 (edited) If you have physics bodies with collideWorldBounds=true they will be immediately moved inside the physics world bounds if they were created outside it. If you change the camera bounds such that the camera is outside them them it will immediately move to the nearest edge. If you have the camera follow a sprite it will move immediately (unless lerped) to center on the sprite. I would try to get everything in your game positioned as you want first before configuring the camera at all, because it can get confusing once the camera starts moving. Edited November 30, 2018 by samme different bounds Link to comment Share on other sites More sharing options...
samme Posted November 29, 2018 Share Posted November 29, 2018 On 11/28/2018 at 4:45 AM, zetsubou said: this.cameras.main.viewPort(window.innerWidth, window.innerHeight, 200, 1800) There's no viewPort method. Make sure you have the console open to catch errors! Link to comment Share on other sites More sharing options...
zetsubou Posted November 30, 2018 Author Share Posted November 30, 2018 15 hours ago, samme said: If you have physics bodies with collideWorldBounds=true they will be immediately moved inside the bounds if they're created outside it. If you change the camera bounds such that the camera is outside them them it will immediately move to the nearest edge. If you have the camera follow a sprite it will move immediately (unless lerped) to center on the sprite. I would try to get everything in your game positioned as you want first before configuring the camera at all, because it can get confusing once the camera starts moving. That's how it works! Now it makes much more sense for me, than before. Thank you! Link to comment Share on other sites More sharing options...
Recommended Posts