I think you left out a super drawOn: aCanvas in your method. Interesting to hear if this works:

drawOn: aCanvas
   aCanvas borderWidth:10; borderColor: Color green.
   *super**drawOn: aCanvas.*
The rest should work AFAICS, but it could be simplified.
(I haven't Pharo available so that I can test it)
--Trygve

On 04.02.2015 19:00, nacho wrote:
Hi,
I have the following question:
I want to draw a bouncing ball.
First thing I do is create a class:

EllipseMorph subclass: #Ball
        instanceVariableNames: 'position'
        classVariableNames: ''
        category: 'PBE-BouncingBall'


Then an initialization method that mostly do a super initialize.
Then the drawOn:
drawOn: aCanvas
        aCanvas borderWidth:10; borderColor: Color green.


And finally a position method:

position: aPoint
        super position: aPoint.

position
        ^ position.


Finally in a Playground I do:

| aBall |

aBall := Ball new.
aBall position: ( 10@10 ).
aBall openInWorld.

But I get a red box with two crossing yellow lines.
What I'm missing?

Thanks in advance.
Nacho




-----
Nacho
Smalltalker apprentice.
Buenos Aires, Argentina.
--
View this message in context: 
http://forum.world.st/Question-on-Morphic-drawOn-method-tp4803695.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

Reply via email to