I have to add a second viewport (= like splitscreen) to allow the player to see an event somewhere else on the current level.
Is there any possibility to draw the event area without redrawing every things already drew ?
[EDIT] RenderTarget2D is the key. Thx User1459910 for all.
It almost worked.
New questions :
- I've searched for a while and still don't find a tutorial about "Xna 2D camera with source and destination rectangle" if you have a link, i'd like to see it, please ♥</li>
Currently, the drawing code looks like this :
protected override void Draw(GameTime gameTime) { /* ... here is the code to "draw" in the renderTarget2D renderAllScene object ... */ //Let's draw into the 2 viewports spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, camera1.transform); spriteBatch.Draw(renderAllScene, viewport1.Bounds, Color.White); spriteBatch.End(); if (EventIsRunning) { spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, null, null, null, camera2.transform); spriteBatch.Draw(renderAllScene, viewport2.Bounds, Color.White); spriteBatch.End(); }
*The Viewport 1 is great. The camera follows the character but after moving the camera for a short distance, the map is cutted at 1280pixels i think. so it drew only 1280pixels of all the map. I don't know why. Maybe because i failed when i created renderAllScene = new RenderTarget2D. :x
renderAllScene = new RenderTarget2D(GraphicsDevice, GraphicsDevice.PresentationParameters.BackBufferWidth, GraphicsDevice.PresentationParameters.BackBufferHeight);
*For the Viewport 2 : I need the source rectangle. I'll try it tomorrow.