MikeW Posted April 10, 2017 Report Share Posted April 10, 2017 Using p2 I want to block off the top 100 pixels for a score areas. Is there a way to make the world take the bottom 500 pixels. Quote Link to comment Share on other sites More sharing options...
RubbleGames Posted April 10, 2017 Report Share Posted April 10, 2017 I've never tried using it for this purpose, but have you tried game.world.setBounds? http://phaser.io/docs/2.6.2/Phaser.World.html#setBounds Quote Link to comment Share on other sites More sharing options...
snowbillr Posted April 11, 2017 Report Share Posted April 11, 2017 If that top area is going to be completely separate from the game area, an option would be to not make it part of the Phaser game at all, but rather a separate element on the page. It's Just Javascript™ so you can update the content of that area when something happens in your game. mattstyles 1 Quote Link to comment Share on other sites More sharing options...
MikeW Posted April 11, 2017 Author Report Share Posted April 11, 2017 That could work I got the world shifted I have code like var bounds = new Phaser.Rectangle(0, 0, 400, 400); customBounds = { left: null, right: null, top: null, bottom: null }; createPreviewBounds(bounds.x, bounds.y, bounds.width, bounds.height); Of the example and txtScore = game.add.text(100,-90, "Coins",style3); to put stuff in the area above the world. Quote Link to comment Share on other sites More sharing options...
snowbillr Posted April 11, 2017 Report Share Posted April 11, 2017 Nice! Glad you found a solution that worked. If your UI gets more complicated, it might make sense to create two Phaser.Group objects, one for the UI on top, and one for the game area underneath. You could add all your ui objects to the UI group and all your game objects to the game area group. I believe, although I don't have a ton of experience with it, that if you set the position for a group, all of the group's children will be positioned relative to where the group is. So adding a child to the UI group will mean that it's positioned in that top area, and adding a child to the game area group will mean its positioned relative to the bottom area. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.