|
Dependencies Question: msg#00758lang.smalltalk.squeak.general
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
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | RE: Cannot install Squeak v. 3.2-4, Jarvis, Robert P. (Contingent) |
|---|---|
| Next by Date: | Re: Dependencies Question, Diego Gomez Deck |
| Previous by Thread: | Cannot install Squeak v. 3.2-4, Serban Udrea |
| Next by Thread: | Re: Dependencies Question, Diego Gomez Deck |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |