Hi diego
Thanks. I followed my investigation. I saw it after. Still the issue of
changed defined this way on Morph keeps me perplex.
Stef
On lundi, juillet 29, 2002, at 10:37 PM, Diego Gomez Deck wrote:
Hi Stef,
I think that the problem is here:
BreakOut>>udpate
Transcript show: 'Breakout update' ; cr
it must be:
BreakOut>>udpate: aParameter
Transcript show: 'Breakout update' ; show: aParameter; cr
The #changed: method is supposed to pass a parameter telling which aspect
of the object had changed. so here, the code must be:
Field>>score: aNumber
score := aNumber.
self changed: #score
Hoping that helps,
Diego Gomez Deck
Hi
I'm building a breakOut for my book and I have the following problem.
I have one object that contains the score of the game that get increased
each time a brick is destroyed.
Now I copied a bit the code of the SameGame to get a list of button
around my game field and in particular I want to display the score. So
here is my question.
In VisualWorks I would changed the Field score instance variable into a
value holder and I will initialize the BreakOut class to get notify
whether the score variable changes.
How can I do the same in Squeak?
I started to
Field>>score: aNumber
score := aNumber.
self changed
BreakOut>>initializeToStandAlone
...
self field addDependent: self
BreakOut>>udpate
Transcript show: 'Breakout update' ; cr
But I got nothing.
I checked a bit and I was surprised to see that dependents are still
managed in Squeak via the DependentFields. I read in old VW tutorials
and books that this way of doing things was bad because all the
dependents were stored in the same dict. I checked and Model is there :)
But Morph does not implement a different ways of storing dependents.
Then I checked
Morph>>changed
"Report that the area occupied by this morph should be redrawn."
^fullBounds
ifNil:[self invalidRect: self outerBounds]
ifNotNil:[self invalidRect: fullBounds]
And realized that Morph was simply breaking the dependency
protocol.....(no comment)
So here is my question:
- how do we get notification and registration in Squeak for a
morph?
Stef
PS: The dependencies mechanism start to be old and broadcasting too much.
Is there somebody thinking about a new architecture? Events or
DependencyTransformer like in VW ....
Dr. Stéphane DUCASSE (ducasse@xxxxxxxxxxxx)
http://www.iam.unibe.ch/~ducasse/
"if you knew today was your last day on earth, what would you do
different? ... especially if, by doing something different, today
might not be your last day on earth" Calvin&Hobbes
|