[Newbies] [Q] What is wrong here ?

Jerome Peace peace_the_dreamer at yahoo.com
Sat May 9 01:19:35 UTC 2009





--- On Thu, 5/7/09, Edgar J. De Cleene <edgardec2001 at yahoo.com.ar> wrote:

> From: Edgar J. De Cleene <edgardec2001 at yahoo.com.ar>
> Subject: [Newbies] [Q] What is wrong here ?
> To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners at lists.squeakfoundation.org>
> Date: Thursday, May 7, 2009, 9:23 AM
> Folks:
> I try to made aq very simple MahJongg  with this info links
> http://en.wikipedia.org/wiki/Mahjong_solitaire
> http://home.halden.net/vkp/vkp/
> 
> For made the grid I made
> 
> grid := OrderedCollection new.


> 
> madeThisRowFor: aInteger at: aPoint
>     | topRow square newSquare |
>     topRow := AlignmentMorph newRow.
>     topRow position: aPoint.
>     topRow openInWorld.
>     square := Morph new.
>     square color: Color transparent;
>          borderWidth: 2;
>          extent: 45 @ 54;
>          borderColor: Color blue.
>     1
>         to: aInteger
>         do: [:c | 
>             newSquare := square copy.
>             topRow addMorph: newSquare.
>             grid add: topRow submorphs last center].
>   
> 
> Don¹t work as grid is populated by same values .
> Example: 
> self madeThisRowFor: 12 at: 0 @ 0.
> 
> Grid an OrderedCollection(22 at 27 22 at 27 22 at 27 22 at 27 22 at 27
> 22 at 27 22 at 27 22 at 27
> 22 at 27 22 at 27 22 at 27 22 at 27)
> 
> But if I put self half before
> 
> grid add: topRow submorphs last center
> 
> I got
> 
> an OrderedCollection(24 at 29 69 at 29 114 at 29 etc )
> 
> Really odd, some could explain ?

You have left out some important details.
There seems to be a class involved.
What is it. Is grid an ivar of that class?

====
Also, Why not do a mockup in a workspace first?
Why not just create the row then collect the centers from the submorphs?

e.g.
squarePrototype := what you said for square.

topRow := what you said for topRow

anInteger timesDo: [ topRow addMorph: squarePrototype copy ] .

then make

grid := topRow submorphs collect: [ :each | each center ] .
 

Yours in curiosity and service, -Jerome Peace




      


More information about the Beginners mailing list