xTile Viewport Screen Location

Sep 23, 2011 at 5:49 PM

I have a feeling that there's a really simple answer to this, but it's eluding me right now.

I'm using xTile maps for things that aren't really maps, like dialog boxes. I'd like to set the map dimensions to something the size of the dialog box, and render it at a defined position. However, it seems that my xTile maps always render starting at the (0, 0) point, and trying to adjust the X, Y, Height, Width, Location.X, and Location.Y parameters of my viewport only adjust the size and focus of the viewport. Changing the X and Y does the same thing as changing the Location, which moves the map up or down within the viewport. What parameters determine the actual screen rendering position of the viewport?

My current workaround is to make the map the exact dimensions of the screen and put the content where I want it, but I'd rather have a variable rendering location, so I can display the content in different places.

 

Sep 24, 2011 at 12:39 AM

You should be able to offset the dialog box "map" using the displayOffset parameter in one of the Map.Draw method overrides. However, you should use multiples of your tile size for your position as the clipping isn't working properly with the current version. Otherwise, it should work just fine.

Sep 24, 2011 at 1:39 AM

Something about my rendertarget bounds is giving me an error when I give it an offset over 32 or so. That might just be because of how I'm using a rendertarget for scaling, but I don't think the map is actually going off the bounds.

I get this error on my Map.Draw() call: "The viewport is invalid. The viewport cannot be larger than or outside of the current render target bounds. The MinDepth and MaxDepth must be between 0 and 1. Parameter name: value"

Just to confirm, I tried giving my main map an offset and got the same result. Both are drawing within my rendertarget, so for now I'm going to just blame it on that and use the workaround.

Sep 24, 2011 at 2:51 PM

To be honest I have never tested the engine with different render targets but used the GraphicsDevice entity as provbded by the Game object. Have you tried making the viewport very small and then experiment by increasing the size? Perhaps you have to take into consideration the scaling factor?