antbrooksuk Posted July 3, 2014 Share Posted July 3, 2014 I have a large stage with a top down view.I'd like to draw elements fixed to the viewport rather than relative to the stage.I can't see a way of making a container fit to the viewport. Any help appreciated! Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 4, 2014 Share Posted July 4, 2014 Would it work for you to make two containers - one for the HUD and one for content, then move the content layer around only? I know tho isn't exactly what you're looking for, but it might be a workaround. Quote Link to comment Share on other sites More sharing options...
nacs Posted July 4, 2014 Share Posted July 4, 2014 Ninja is correct. The best way seems to be to create 2 containers and move the content container around as needed. The alternative is to dynamically offset the position of every HUD element based on the viewport but that will get messy. Quote Link to comment Share on other sites More sharing options...
antbrooksuk Posted July 4, 2014 Author Share Posted July 4, 2014 Thanks, for clarification: I do have a separate container for the controls.I have a camera following a sprite on the main stage which is quite large.When I draw to the controls container the items are being drawn relative to the stage. I can't seem to find a way to keep the controls layer fixed to the viewport. Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 4, 2014 Share Posted July 4, 2014 Can you lock the controls container to the x and y of the camera? Quote Link to comment Share on other sites More sharing options...
antbrooksuk Posted July 4, 2014 Author Share Posted July 4, 2014 Genius, thanks! this.controls.position.x = game.scene.camera.camera.position.x;this.controls.position.y = game.scene.camera.camera.position.y; Quote Link to comment Share on other sites More sharing options...
Ninjadoodle Posted July 4, 2014 Share Posted July 4, 2014 Awesome Happy I could help! 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.