I've been working through Stephen Wessel's fantastic Laser Game tutorial, and have enjoyed the process a great deal. I've gotten to the part where the tutorial describes using Morphic to create the UI for the game.
http://squeak.preeminent.org/tut2007/html/068.html When I get to the part where tutorial describes creating the 'Fire' and 'Quit' buttons, though, I get an unexpected result. The buttons are vastly oversized. I've checked the code and the tutorial several times, so I don't think I've typed in any erroneous code. I've also browsed the PluggableButtonMorph class to see if I could remedy the problem by finding out which methods to call to re-size the buttons into something that approximates what the tutorial describes. Yet I have not been able to do so. Can someone help me out with this section of the tutorial? Thanks, Paul -- _______________________________________________ Get your free email from http://mail.doramail.com Powered by Outblaze _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Hi,
maybe I can help you find the problem. > When I get to the part where tutorial describes creating the 'Fire' and 'Quit' buttons, though, I get an unexpected result. The buttons are vastly oversized. I've checked the code and the tutorial several times, so I don't think I've typed in any erroneous code. What do you mean by oversized? Are they still contained in the control panel morph? A good way to check the embedding of morphs in containers is to bring up the Halo: first you get the halo of the outer morph, click again to get the halo of the next embedded morph etc. Another way is to give different morphs different colors. E.g.: panel color: Color blue Can you send a screenshot of how these buttons look like? > I've also browsed the PluggableButtonMorph class to see if I could remedy the problem by finding out which methods to call to re-size the buttons into something that approximates what the tutorial describes. Yet I have not been able to do so. The size of the buttons is controlled by the control panel morph that contains them. Look in makeControlPanelMorph, it sets a LayoutPolicy in the beginning. Then the buttons are added using addMorph:fullFrame:. hope this helps Matthias _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
In reply to this post by ina tube
>
> > Hi, > > maybe I can help you find the problem. > Thanks! I appreciate your help. > > When I get to the part where tutorial describes creating the > > 'Fire' and 'Quit' buttons, though, I get an unexpected result. > > The buttons are vastly oversized. > > What do you mean by oversized? Are they still contained in the control > panel morph? A good way to check the embedding of morphs in containers > is to bring up the Halo: first you get the halo of the outer morph, > click again to get the halo of the next embedded morph etc. Another > way is to give different morphs different colors. E.g.: > > panel color: Color blue > > Can you send a screenshot of how these buttons look like? > hope this helps I'm attaching 2 screen captures of the oversized buttons. I've changed the button colors, as you've suggested. In the second screen capture, I've raised the halo. The halo surrounds the Quit button. The Fire button is covered by the Quit button, with only the top portion of the Fire button protruding. As indicated in the tutorial, I use the following commands to attach the buttons. panel := RectangleMorph new borderWidth: 0; color: Color white; layoutPolicy: ProportionalLayout new. buttonHeight := 26. vertOffsetTop := 10 + buttonHeight + 10 + buttonHeight. vertOffsetBtm := 10 + buttonHeight + 10. panel addMorph: self makeFireLaserButton fullFrame: (LayoutFrame fractions: (0@0 corner: 1@1) offsets: ( (20 @ (vertOffsetTop negated)) corner: (-20 @ (vertOffsetBtm negated)) ) ). vertOffsetTop := 10 + buttonHeight. vertOffsetBtm := 10. panel addMorph: self makeQuitGameButton fullFrame: (LayoutFrame fractions: (0@0 corner: 1@1) offsets: ( (20 @ (vertOffsetTop negated)) corner: (-20 @ (vertOffsetBtm negated)) ) ). ^panel Thanks again, Paul -- _______________________________________________ Get your free email from http://mail.doramail.com Powered by Outblaze _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |