If I have a morph that is stepping through some process I know I can test for whether or not it is still stepping by using the isStepping method. But, how to I put this into a loop so that the next instruction doesn't start until the stepping is done.
Here is my mouseDown code. I want to put something in before the last instruction so it doesn't execute until isStepping becomes false.
mouseDown: evt
path := OrderedCollection new.
0 to: 9 do: [:i | path add: self position + (0@(10 * i))].
path := path, path reversed.
self startStepping.
self owner moveTheGameBall.
On 07.11.2009, at 14:18, Christine Wolfe wrote:
If I have a morph that is stepping through some process I know I can test for whether or not it is still stepping by using the isStepping method. But, how to I put this into a loop so that the next instruction doesn’t start until the stepping is done.
Here is my mouseDown code. I want to put something in before the last instruction so it doesn’t execute until isStepping becomes false.
mouseDown: evt path := OrderedCollection new. 0 to: 9 do: [:i | path add: self position + (0@(10 * i))]. path := path, path reversed. self startStepping.
self owner moveTheGameBall.
Not possible in Morphic (that is one of the major advantages of Tweak).
The canonical way is to test for the end condition in #step. Something like
step path ifEmpty: [^self stopStepping]. self position: path removeFirst. path ifEmpty: [self owner moveTheGameBall]
- Bert -
Wow! That worked. But I'm sorry to hear that morph doesn't support a loop like I wanted. That sounds restrictive but maybe I just need more time in world to become squeakified.
Thank you SO MUCH
-----Original Message----- From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners-bounces@lists.squeakfoundation.org] On Behalf Of Bert Freudenberg Sent: Saturday, November 07, 2009 8:30 AM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] isStepping question
On 07.11.2009, at 14:18, Christine Wolfe wrote:
If I have a morph that is stepping through some process I know I can test for whether or not it is still stepping by using the isStepping method. But, how to I put this into a loop so that the next instruction doesn't start until the stepping is done.
Here is my mouseDown code. I want to put something in before the last instruction so it doesn't execute until isStepping becomes false.
mouseDown: evt path := OrderedCollection new. 0 to: 9 do: [:i | path add: self position + (0@(10 * i))]. path := path, path reversed. self startStepping.
self owner moveTheGameBall.
Not possible in Morphic (that is one of the major advantages of Tweak).
The canonical way is to test for the end condition in #step. Something like
step path ifEmpty: [^self stopStepping]. self position: path removeFirst. path ifEmpty: [self owner moveTheGameBall]
- Bert -
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
On 07.11.2009, at 14:45, Christine Wolfe wrote:
Wow! That worked. But I'm sorry to hear that morph doesn't support a loop like I wanted. That sounds restrictive but maybe I just need more time in world to become squeakified.
Actually that's a restriction of about any event-driven GUI. Your code must not wait until some event occurs because the other UI elements would be blocked by that. Everything (e.g. event handling, animation, painting) is done in call-back methods, the main loop calls your code which must return ASAP.
The only way around that is by using background processes, which is possible in Squeak of course, but usually introduces many more problems than it solves. Better adhere to the standard practices, which is do-one-thing-and-return.
- Bert -
Thank you so much for the explanation. I will keep that philosophy in mind as I try to figure out other techniques as well.
-----Original Message----- From: beginners-bounces@lists.squeakfoundation.org [mailto:beginners-bounces@lists.squeakfoundation.org] On Behalf Of Bert Freudenberg Sent: Saturday, November 07, 2009 10:40 AM To: A friendly place to get answers to even the most basic questions about Squeak. Subject: Re: [Newbies] isStepping question
On 07.11.2009, at 14:45, Christine Wolfe wrote:
Wow! That worked. But I'm sorry to hear that morph doesn't support a loop like I wanted. That sounds restrictive but maybe I just need more time in world to become squeakified.
Actually that's a restriction of about any event-driven GUI. Your code must not wait until some event occurs because the other UI elements would be blocked by that. Everything (e.g. event handling, animation, painting) is done in call-back methods, the main loop calls your code which must return ASAP.
The only way around that is by using background processes, which is possible in Squeak of course, but usually introduces many more problems than it solves. Better adhere to the standard practices, which is do-one-thing-and-return.
- Bert -
_______________________________________________ Beginners mailing list Beginners@lists.squeakfoundation.org http://lists.squeakfoundation.org/mailman/listinfo/beginners
Bert:
Is Croquet the only way to use Tweak nowadays? Is is possible to load Tweak into Squeak or Pharo?
Thanks in advcance!
On Sat, Nov 7, 2009 at 14:30, Bert Freudenberg bert@freudenbergs.de wrote:
Not possible in Morphic (that is one of the major advantages of Tweak).
On 07.11.2009, at 22:43, Alex Schenkman wrote:
Bert:
Is Croquet the only way to use Tweak nowadays?
It's only maintained in Croquet currently, but you can use it without the 3D stuff if you want.
The Sophie image contains Tweak, too.
Is is possible to load Tweak into Squeak or Pharo?
The Croquet image *is* a Squeak image of 3.8 heritage, and contains instructions on how to load Tweak. It's not easy to load into a more recent version though.
- Bert -
beginners@lists.squeakfoundation.org