I've been playing with a Morphic implementation of "Joe the box" for an intro programming course. It shouldn't be hard, right?

The problem is rotation. It's easy to rotate a polygon morph, but I can't get a TextMorph (for the name) to rotate and stay centered. My next attempt (attached), was to use a transformation morph. This almost works, except that when rotating from a non-manhattan orientation, smurfs get left on the display.

The code is attached.


Attachment: CS520-MorphicBoxes.st
Description: Binary data




I try doing this in a workspace:

joe := NamedBoxMorph2 new.
joe name: 'Fred'.
joe openInWorld.
joe color: Color lightBlue.
joe turn: -45.
joe turn: 45.

Do the

        joe turn: +/- 45

a few times. Bits of the rectangle are left on the display. Is this a bug in morphic, or a bug in my code (more likely)? Is tehre an easy fix/

The critical method from the filein is this one, I think:

BoxMorph2 >> initialize
        "initialize this BoxMorph so that it looks like a Box in BoxWorld"
        | rectangle b |
        super initialize.
        smoothing := 3.
        b := Rectangle origin: 85 @ 200 extent: 80 @ 80.
        rectangle := RectangleMorph new.
        rectangle bounds: b.
        rectangle color: Color transparent.
        rectangle borderWidth: 1.
        self addMorphCentered: rectangle.
        self bounds: b.

I tired making the bounds of the boxMorph a pixel or two bigger (in the last line): this didn't help.

Any ideas?

        Andrew

_______________________________________________
Pharo-project mailing list
[email protected]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project

Reply via email to