Hello Jeff :-)
interesting question, and I know the situation you're describing with respect to getting the help you want. OK, to the point of your problem: you want to turn a Wonderland actor (your helicopter) in response to a mouse click. Here is a quick, concrete recipe, tested in Squeak 3.8: 1) As you did, evaluate ("do it" ) this: | wonder copter | wonder := Wonderland new. copter := wonder makeActorFrom: 'WonderlandObjects\Vehicles\Helicopter.mdl'. 2) Now _within_ the wonderland script window, evaluate this: helicopter addResponse: [:event | helicopter turn: #left] to: #leftMouseUp 3) click on your helicopter and see what happens Does that do what you want? ------------ Now, how did I find out about this? (I'm not saying you should be able to find this out for yourself, mind you. I'm just trying to help.) 1) Notice the Quick reference tab in the wonderland window 2) Somewhere down in that text you find Adding Reactions -------------------- Useful constants: event types: keyPress, leftMouseDown, leftMouseUp, leftMouseClick, rightMouseDown, rightMouseUp, rightMouseClick addResponse: <block> to: <eventType> removeResponse: <response> to: <eventType> respondWith: <block> to: <eventType> 3) So it has to be something with addResponse. I still don't know how to use the addResponse, however. So I open the method finder and type in addResponse 4) I find the method addResponse:to: in WonderlandActor 5) looking at the method source code in the browser, I don't get a idea of how to use it. In most cases it's better to look at examples of the method in use, so I click on "senders" 6) bummer: there are no senders of addResponse:to: ! 7) in that same method category "event handling" there is another method that looks similar: respondWith:to:, and that's also listed in the wonderland quick reference 8) I find 3 senders of respondWith:to:, among them initializeDefaultReactions "Set up our default reactions" myReactions := Dictionary new. self respondWith: [:event | self onLeftMouseDown: event] to: leftMouseDown. self respondWith: [:event | self onLeftMouseUp: event] to: leftMouseUp. 9) So I interpret the method as this: There is a dictionary myReactions that tells the actor what to do in response to an event. Event types are the keys, blocks are the value of this dictionary. They initialize the reactions to left mouse down and left mouse up with blocks that specify what to do on these events. Now it makes sense: the block takes the event as an argument, so you can ask the event object e.g. for the mouse coordinates 10) Now I have the basic format for the block, and an example on how to use it 11) The last obstacle was to be able to "name" the helicopter inside the wonderland, because it takes on its own name ("helicopter" instead of the "copter" you used in the script). I fully realize that this discovery process needs a lot of assumptions and background knowledge about Squeak. I think this knowledge can be gradually accumulated by playing with the system and trying to get small things done. When you're stuck, you can always ask the mailing list. -------- I hope this helps, have fun. Matthias On 11/7/06, Jeff <[hidden email]> wrote: Hello group! _______________________________________________ Beginners mailing list [hidden email] http://lists.squeakfoundation.org/mailman/listinfo/beginners |
Free forum by Nabble | Edit this page |