Search the Community
Showing results for tags 'setBounds'.
-
in my scene's create method I'm using this line of code to set bounds. this.matter.world.setBounds(0, 0, 1800, 1800, 15); here, the thickness, is set to 15 as I understand it. But I fly through the walls sometimes and need a more solid barrier. any ideas on how to shore up the world bounds? Alternatively if you know of a way of setting tiles along the world bounds, I'd be fine with that kind of solution...
-
My goal is to make the player stay centered on the canvas at all times, even when he reaches the boundaries of the world. This is how it is now: https://gyazo.com/ea478d70b78201ad51aa6ae09b2649a6 And I've modified the code to be like this: deadland = game.add.tileSprite(world.x1 - 1200, world.y1 - 1200, world.x2*2, world.y2*2, 'deadland'); land = game.add.tileSprite(world.x1, world.y1, world.x2, world.y2, 'earth'); land.fixedToCamera = false; land.boundsPadding = 100; game.world.setBounds(world.x1 -1200, world.y1 -1200, world.x2*2, world.y2*2); game.physics.startSystem(Phaser.Physics.P2JS); deadland.alpha = 0.7; land.alpha = 1; But now the player isn't stopping at the 'earth' size bounds. He goes all the way to the 'deadzone': https://gyazo.com/634d578985d1aef1f6ccb6f51e17f65f How do I do it so the player won't go beyond the 'earth' bounds? Thanks!
-
So I have a code block where Phaser.Game's height and width accommodate the full window size prior to the boot state, upon getting to the Game state I reset the world bounds to accommodate a larger canvas: buildWorld: function() { worldOw = this.world.width; worldOh = this.world.height; this.physics.startSystem(Phaser.Physics.ARCADE); cursors = this.input.keyboard.createCursorKeys(); this.world.setBounds(0, 0, worldW, worldH); /* if (this.camera.bounds) { //The Camera can never be smaller than the game size //game.camera.bounds.setTo(x, y, width, height); //this.camera.bounds.setTo(0,0, worldW, worldH); } */ //this.physics.setBoundsToWorld(); OGpos_PlaneY = this.world.height-250; OGpos_PlaneX = 300; And with modification to the launcher demo launcherUpdate : function(){ plane.anchor.setTo(1, 1); if (catchFlag) { distance = mainST.physics.arcade.distanceBetween(plane, arrow); theta = mainST.physics.arcade.angleToPointer(arrow); analog.rotation = arrow.rotation + Math.PI/2; arrow.rotation = mainST.physics.arcade.angleBetween(plane,arrow); degTheta = Math.round((arrow.rotation * 180)/Math.PI); if(degTheta >= -90 && degTheta <= 90){ if (distance > 75) { distance = 75; var adjacentX = Math.cos(theta) * distance; var oppositeY = Math.sin(theta) * distance; plane.x = OGpos_PlaneX + adjacentX; plane.y = OGpos_PlaneY + oppositeY; } else { plane.x = mX; plane.y = mY; } } else { var adjacentX = Math.cos(theta); var oppositeY = Math.sin(theta); plane.x = OGpos_PlaneX + adjacentX; plane.y = OGpos_PlaneY + oppositeY; } analog.height = distance; arrow.alpha = 1; console.log(degTheta); } if (launched) { plane.anchor.setTo(0.5, 0.5); } }I encounter: Where the plane's transforms interchange between the product of distance = 75;var adjacentX = Math.cos(theta) * distance;var oppositeY = Math.sin(theta) * distance;plane.x = OGpos_PlaneX + adjacentX;plane.y = OGpos_PlaneY + oppositeY;&& plane.x = OGpos_PlaneX + adjacentX;plane.y = OGpos_PlaneY + oppositeY;However with replacing distance = mainST.physics.arcade.distanceBetween(plane, arrow); with distance = mainST.physics.arcade.distanceToPointer(arrow); we get the analog(rubberband) instantly locked with no possible rubber-banding within range of the distance constrain: Has anyone come by a solution or can provide guidance on this?
-
Sprite bounds are working fine when when I am setting world bounds in create function. function create() { game.world.setBounds(0, 0, game.width, 4000); } but when I set it again, so my player can not move backwards when reached to a specific point by this way. function reduceWorld() { game.world.setBounds(0, 0, game.width, 1000);} now bounds are reduced and camera can not go outside bounds but sprite is going outside bounds.I am using follow camera for sprite.any help will be great.