a. Name : vScrollBar1
b. Anchor : Top, Bottom, Right
c. LargeChange : 48
d. Location : 658, 27
e. Size : 17, 576
a. Name : hScrollBar1
b. Anchor : Bottom, Left, Right
c. LargeChange : 48
d. Location : 184, 606
e. Size : 474, 17
FixScrollBarScales()
helper method to the MapEditor class:private void FixScrollBarScales() { Camera.ViewPortWidth = pctSurface.Width; Camera.ViewPortHeight = pctSurface.Height; Camera.Move(Vector2.Zero); vScrollBar1.Minimum = 0; vScrollBar1.Maximum = Camera.WorldRectangle.Height - Camera.ViewPortHeight; hScrollBar1.Minimum = 0; hScrollBar1.Maximum = Camera.WorldRectangle.Width - Camera.ViewPortWidth; }
MapEditor_Load()
method to include a call to FixScrollBarScales():
FixScrollBarScales(): FixScrollBarScales();
MapEditor.cs
in SolutionExplorer to reopen the Design mode view of the MapEditor form. MapEditor_Resize()
method:We now have scroll bars attached to the sides of the game's display area. When the form is initially displayed, and then again whenever it is resized, the scroll bars will be rescaled so that they cover the entire area of the game's tile map.
We will use these scroll bars to move around on the map while editing, though their actual implementation will again be tied to changes to the Game1 class.
3.140.186.201