I've tested your code in Squeak and found another bug (I should have
been more careful when I read your code. Shame on me.)
In class Ball you have the methods
position: aPoint
super position: aPoint.
This does not set a value to your position variable in class Ball, but actually
sets the upper-left corner of the bounds.
You should have said position := aPoint.
--------------------------------
The following now works in mySqueak image:
EllipseMorph subclass: #Ball
instanceVariableNames: 'position'
classVariableNames: ''
poolDictionaries: '' "this part is needed in Squeak"
category: 'ZZZtesting'
drawOn: aCanvas
self borderWidth:10; borderColor: Color green.
super drawOn: aCanvas.
position
^ position.
position: aPoint
position := aPoint.
I then execute the following in a workspace
| aBall |
aBall := Ball new.
aBall position: ( 10@10 ).
aBall openInWorld.
and it seems to work. But closer scrutiny shows that it ignores your
instance variable (position). when I move the ball around.
The reason is that EllipseMorph is a superclass of your Ball and cannot
possibly know about an instance variable (position) that is defined in
the subclass (Ball).
I ignored Ball>position since the EllipseMorph doesn't use it:
EllipseMorph subclass: #Ball
instanceVariableNames: ''
classVariableNames: ''
poolDictionaries: ''
category: 'ZZZtesting'
position
^ super position.
position: aPoint
super position: aPoint.
This looks better.
I you really want to replace the EllipseMorph>position you must go
deeper into how the EllipseMorph handles its position and bounds . This
will not be trivial. Much easier to invent a new instance variable and
use it in the drawOn: method.
Good luck with your apprenticeship
On 05.02.2015 11:56, nacho wrote:
@Trygve
I've checked and it doesn't work. I can't even bring the halo on to delete
the morph. The debugger keeps popping.
Thanks anyway to all
Nacho
-----
Nacho
Smalltalker apprentice.
Buenos Aires, Argentina.
--
View this message in context:
http://forum.world.st/Question-on-Morphic-drawOn-method-tp4803695p4803895.html
Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
--
/The essence of object orientation is that objects collaborateto achieve
a goal. /
Trygve Reenskaug mailto: tryg...@ifi.uio.no <mailto:%20tryg...@ifi.uio.no>
Morgedalsvn. 5A http://folk.uio.no/trygver/
N-0378 Oslo http://fullOO.info
Norway Tel: (+47) 22 49 57 27