Thanks @Jjagg , you just replied as I was about to post this:
I’ve knocked up something and it seems to work - worked out how to change the colour of the white image too, this is a little example of what I’ve come up with:
- Resolution is the virtual screen manager class I have, this sets up the design area and the view size.
public GameRegionTest()
{
IsMouseVisible = true;
_graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
//Change Virtual Resolution
Resolution.Initialize(_graphics);
Resolution.SetVirtualResolution(1920, 1080);
Resolution.SetResolution(960, 540, false);
}
-
In the draw() I then call a sub method “DrawRegions()” which then draws the regions to a renderTarget2D, returning a texture2D
-
Draw the returned texture 2D to the screen.
4, I also draw out each of the regions to the screen. - I’m guessing this is the WORSE way to do it and #2 is the better way.
protected override void Draw(GameTime gameTime)
{
Resolution.BeginDraw();
_spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.PointClamp, null, null, null, null);
// DRAW All the regions on a render target, then draw the full image to the screen
Texture2D regions = DrawRegions(_graphics.GraphicsDevice);
_spriteBatch.Draw(regions, new Vector2(0,0), Color.White);
// Draw each region individually.
_spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 0, _regionUK.Height), Color.Red);
_spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 1, _regionUK.Height), Color.Yellow);
_spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 2, _regionUK.Height), Color.Blue);
_spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 3, _regionUK.Height), Color.Green);
_spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 4, _regionUK.Height), Color.Brown);
_spriteBatch.End();
base.Draw(gameTime);
}
private Texture2D DrawRegions(GraphicsDevice graphicsDevice)
{
var renderTarget2D = new RenderTarget2D(graphicsDevice, Resolution.VirtualViewport.Width, Resolution.VirtualViewport.Height);
var spriteBatch = new SpriteBatch(graphicsDevice);
graphicsDevice.SetRenderTarget(renderTarget2D);
spriteBatch.Begin();
spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 0, 0), Color.Red);
spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 1, 0), Color.Yellow);
spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 2, 0), Color.Blue);
spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 3, 0), Color.Green);
spriteBatch.Draw(_regionUK, new Vector2(_regionUK.Width * 4, 0), Color.Brown);
spriteBatch.End();
graphicsDevice.SetRenderTarget(null);
return (Texture2D)renderTarget2D;
}
Yes, at the moment, I’m drawing the same region and in different colours, but I’m sure if I have a list of the region “objects” with a X,Y location to draw them I can build up a “world map” using this method to the render target object then return the final texture to be drawn to the screen.
Does this sound the best way to do what I want to achieve?
Thanks again