grumpygamer Posted June 23, 2015 Share Posted June 23, 2015 I've read the documentation that says: Updates the size of this world and sets World.x/y to the given values The Camera bounds and Physics bounds (if set) are also updated to match the new World bounds. So for example if I have a 320 x 200 canvas and want to extend that to 480 x 380 (random numbers here) I would do:game.world.setBounds(0,0,480,380);BUT would that yield this result or this result Would I have to give negative margins if it presently outputs result 1? Thanks Link to comment Share on other sites More sharing options...
AzraelTycka Posted June 23, 2015 Share Posted June 23, 2015 Hello, you can add a simple graphics to your world with extended bounds to see where (0, 0) point is, that should tell you what you are looking for, or not? Did I understand your question correctly? Link to comment Share on other sites More sharing options...
grumpygamer Posted June 23, 2015 Author Share Posted June 23, 2015 hmm yes, I did so and result is number 1.So how would I go about centering? I tried negative values but it does not seem to work It seems I have to use negative values (now working) and then reposition the camera... Link to comment Share on other sites More sharing options...
grumpygamer Posted June 23, 2015 Author Share Posted June 23, 2015 (edited) I still can't understand centering.If I add let's say 100px on the left and right of the screen like this:var game = this.game; bound_margin = 100; newLeft = this.game.world.bounds.left-bound_margin; newRight = this.game.world.bounds.right+bound_margin; game.world.setBounds(newLeft, 0, newRight, window.innerHeight); // THIS MUGHT BE WRONG bg = game.add.tileSprite(newLeft, 0, newRight, window.innerHeight, 'background');and then add some camera panning like so: update: function() { if (cursors.left.isDown) { this.game.camera.x -= bound_margin; } if (cursors.right.isDown) { this.game.camera.x += bound_margin; }}the camera only moves to one side! Edit:----------------------------------------------- Also what I don't understand is why even with the new bounds in place the ship drawing point still remains at the top left of the window.It should be out of the window? Edited June 23, 2015 by grumpygamer Link to comment Share on other sites More sharing options...
grumpygamer Posted June 24, 2015 Author Share Posted June 24, 2015 Ok, I've just understood by myself. There is no particular need to set negative boundaries UNLESS you want to then calculate a 0-based area. You only need to create the new bounds starting at 0,0, make them as big as you like, THEN center the camera.Job done. Link to comment Share on other sites More sharing options...
Recommended Posts