isStepping question

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

isStepping question

Christine Wolfe

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.

 


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: isStepping question

Bert Freudenberg

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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

RE: isStepping question

Christine Wolfe
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: [hidden email]
[mailto:[hidden email]] 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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: isStepping question

Bert Freudenberg
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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

RE: isStepping question

Christine Wolfe
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: [hidden email]
[mailto:[hidden email]] 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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: isStepping question

Alex Schenkman
In reply to this post by Bert Freudenberg
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 <[hidden email]> wrote:

Not possible in Morphic (that is one of the major advantages of Tweak).
 

_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: isStepping question

Bert Freudenberg
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 mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners