[Newbies] Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?

Jerome Peace peace_the_dreamer at yahoo.com
Sun Oct 25 22:43:23 UTC 2009


Hi Mike,

When you drop an image in not only creates a Sketch with the image it also adds the image form to the internal dictionary of forms.

Try this. 
Get a Rectangle. 
>From the halo menu select>fill style>bitmap fill.
 (You get the default picture)
Get the halo menu again. (needs to be a new menu)
 Select>fill style>choose new graphic.
  (you will get a selection of the internal dictionary's forms to choose from. Press prev and/or next until you see a thumbnail of your card. Press ok.)
 From the fill style menu select>change origin.
  (you get a handle that translates the form. Usually you will just want the topLeft corner of the form to be in the topLeft corner of the rectangle.)
 Once the alignment is done use the yellow halo to resize the rectangle.

If you have a jpg of the sheet of all cards, you only need to load the one picture, then use the origin changing trick to clip to the right one.
Use one Morph for assembly, then copy it each time you have a new card image.

Once I have a bitmap fill I usually copy the "change origin" and "choose new graphic" menu items so I don't have to constantly go back to the halo menu.

This trick will work with any fillable morph. So you could make a card class and then fill them with you deck.

You might also want to find the squeak Freecell application. It probably has a good lot of the stuff you are trying to do. It also comes with its own deck of cards. Older squeak images had this application in the "full" image. Or it might be in the game application. I'm not sure where currently.

Hth,

Yours in curiosity and service, --Jerome Peace



--- On Sun, 10/25/09, Mike Stramba <mikestramba at gmail.com> wrote:

> From: Mike Stramba <mikestramba at gmail.com>
> Subject: [Newbies] Drag and dropped jpg (playing cards) - how to put in the "new morph" menu and create a PlayingCard class?
> To: "A friendly place to get answers to even the most basic questions about Squeak." <beginners at lists.squeakfoundation.org>
> Date: Sunday, October 25, 2009, 2:29 AM
> I'm runninng squeak 3.10.2 on windows
> XP.
> 
> If I drag and drop a jpg onto Squeak, it creates a
> SketchMorph.
> 
> Specficially, I'm adding a playing card image, well 52 of
> them, and
> I'd like to be able to add a card from the world menu / new
> morph
> menu.
> 
> I'd also like to create a PlayingCard class, that uses the
> dropped jpg.
> 
> At the moment I'm doing it the "hard way", after dropping
> the jpg, I'm
> digging through system dictionary, digging out the world
> objects, and
> "drilling down" to the dropped object.
> 
> Any tips, info appreciated.
> 
> Mike
> _______________________________________________
> Beginners mailing list
> Beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/beginners
> 


      


More information about the Beginners mailing list