Section 2

Back to our LaserGame morph. We were working on changing the "Fire" button label to be set dynamically with the state of the laser beam in the grid.

We should change the method that answers the laser's state to actually use the grid now.

Here's a method that will answer the correct button label.

The corresponding change to use the label when we create the button.

Next, we need to enhance our #fireLaser method. This method is called whenever someone clicks on our "Fire" button. There's a design choice we can make here. On one hand we can change the button itself to send the proper message whenever it is clicked - like we already do for the label, or we could change this #fireLaser method to handle both cases.

We may go back and change the button on-the-fly, but for now this will work fine.

When the button will be clicked we will cause the model to activate or stop the laser. But our drawing does know anything has happened. We need a little more code.

Let's open up a new LaserGame morph and see how it works now.

Index Page Next Page

Copyright © 2007, 2008, 2009, 2010 Stephan B Wessels