Larger Margin Around Game Morph
You may have noticed that trying to move the LaserGame morph can be difficult if the only visible areas are the game board morph itself. Clicking on the game board morph causes it to act on the mouse clicks. It does not pick up the morph and grab it for overall movement. An easy way to fix that is make the margin around the outside of our morph a little larger. This way the user can grab it ant any edge to move it.
While we're making this little tweak we will also make a minor cosmetic change to the control panel. All the code changes we will make will be on the LaserGame class.
The first simple change to make is enlarge the margin. Modify the method as follows.
If this was all we did there would be a problem with the "laser home" visual we created earlier in this tutorial. The problem is that when we specified the position of the laser home visual we just assumed it would always go to the bottom edge of the overall LaserGame morph. When the margin gets substantially larger, like now, that assumption is no longer useful. Modify the #setupMorphs method to account for this.
self layoutPolicy: ProportionalLayout new.
addMorph: self makeControlPanelMorph
fractions: (0 @ 0 corner: 0 @ 1)
offsets: (self gameMargin @ self gameMargin
corner: (self gameMargin + self panelWidth) @ self gameMargin negated)).
addMorph: self makeGameBoardMorph
fractions: (0 @ 0 corner: 1 @ 1)
offsets: ((self gameMargin + self panelWidth) @ self gameMargin
corner: self gameMargin negated @ self gameMargin negated)).
addMorph: self makeLaserHomeMorph
fractions: (0 @ 1 corner: 0 @ 1)
offsets: ((self gameMargin + self panelWidth + 1)@(self gameMargin negated)
corner: (self gameMargin + self panelWidth + CellRenderer cellExtent x - 2)@(self gameMargin negated + 4))).