Is there an easy way to implement an animation loop?

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

Is there an easy way to implement an animation loop?

Jan Teske
Hi there,

I try to implement a blocking animation so that the process waits for
the animation to be terminated before going ahead. This animation should
lower the extent of a Morph in 20 iterations so that it looks like it
would shrink.

I tried to accomplish that in a '1 to: 20 do:' loop but the Morph is not
updated during the iterations. I tried 'morph changed' but that doesn't
work either. It does work, however, if I fork the animation loop. But
than I have an extra process an need Semaphores to wait for its
execution. That's not as simple as it could be.

Is there any better way than fork and Semaphore? Maybe some force redraw
method I have overlooked?

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

Re: Is there an easy way to implement an animation loop?

Karl Ramberg
Hi
In morphich you should use the step method.

Just add a step method to the morph and start the stepping when you want the animation to start.
I think you must add a self changed or a self layoutChanged at the end of the step method to update the morph.

It's a little more difficult to block all other morphs from update thou. 
But if they run animation, you can stop their stepping and start it again when your animation is done.

Morphic runs in a single process and using other processes will not necessarily give trouble.

You set the desired time between steps with method stepTime and return the millisecond time you would like.

Karl

On Thu, Jan 5, 2012 at 2:15 PM, Jan Teske <[hidden email]> wrote:
Hi there,

I try to implement a blocking animation so that the process waits for the animation to be terminated before going ahead. This animation should lower the extent of a Morph in 20 iterations so that it looks like it would shrink.

I tried to accomplish that in a '1 to: 20 do:' loop but the Morph is not updated during the iterations. I tried 'morph changed' but that doesn't work either. It does work, however, if I fork the animation loop. But than I have an extra process an need Semaphores to wait for its execution. That's not as simple as it could be.

Is there any better way than fork and Semaphore? Maybe some force redraw method I have overlooked?

Thanks in advance!
_______________________________________________
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: Is there an easy way to implement an animation loop?

Karl Ramberg


On Thu, Jan 5, 2012 at 6:00 PM, karl ramberg <[hidden email]> wrote:
Hi
In morphich you should use the step method.

Just add a step method to the morph and start the stepping when you want the animation to start.
I think you must add a self changed or a self layoutChanged at the end of the step method to update the morph.

It's a little more difficult to block all other morphs from update thou. 
But if they run animation, you can stop their stepping and start it again when your animation is done.

Morphic runs in a single process and using other processes will not necessarily give trouble.

 Morphic runs in a single process and using other processes will give you trouble. 

You set the desired time between steps with method stepTime and return the millisecond time you would like.

Karl


On Thu, Jan 5, 2012 at 2:15 PM, Jan Teske <[hidden email]> wrote:
Hi there,

I try to implement a blocking animation so that the process waits for the animation to be terminated before going ahead. This animation should lower the extent of a Morph in 20 iterations so that it looks like it would shrink.

I tried to accomplish that in a '1 to: 20 do:' loop but the Morph is not updated during the iterations. I tried 'morph changed' but that doesn't work either. It does work, however, if I fork the animation loop. But than I have an extra process an need Semaphores to wait for its execution. That's not as simple as it could be.

Is there any better way than fork and Semaphore? Maybe some force redraw method I have overlooked?

Thanks in advance!
_______________________________________________
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: Is there an easy way to implement an animation loop?

Sean P. DeNigris
Administrator
In reply to this post by Karl Ramberg
Karl Ramberg wrote
use the step method.
Yes, and if you had to communicate with Morphic from another process, use #addDeferredUIMessage:
  "m := Morph new openInWorld."
  m center: 100@100.
  [ 100 timesRepeat: [
                WorldState addDeferredUIMessage: [ m position: m position + 1 ].
                (Delay forMilliseconds: 100) wait ] ] fork
Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

RE: Is there an easy way to implement an animation loop?

Jan Teske
In reply to this post by Karl Ramberg
Thank you, I will try it with stepping. Can you tell my what I have to do to prevent stepping as soon as the Morph is created? A 'morph stopStepping' in the initialize method is not helping since there is no world for the morph at this time. What shall I do instead?

Thanks!
________________________________________
From: [hidden email] [[hidden email]] On Behalf Of karl ramberg [[hidden email]]
Sent: Thursday, January 05, 2012 6:00 PM
To: A friendly place to get answers to even the most basic questions about      Squeak.
Subject: Re: [Newbies] Is there an easy way to implement an animation loop?

Hi
In morphich you should use the step method.

Just add a step method to the morph and start the stepping when you want the animation to start.
I think you must add a self changed or a self layoutChanged at the end of the step method to update the morph.

It's a little more difficult to block all other morphs from update thou.
But if they run animation, you can stop their stepping and start it again when your animation is done.

Morphic runs in a single process and using other processes will not necessarily give trouble.

You set the desired time between steps with method stepTime and return the millisecond time you would like.

Karl

On Thu, Jan 5, 2012 at 2:15 PM, Jan Teske <[hidden email]<mailto:[hidden email]>> wrote:
Hi there,

I try to implement a blocking animation so that the process waits for the animation to be terminated before going ahead. This animation should lower the extent of a Morph in 20 iterations so that it looks like it would shrink.

I tried to accomplish that in a '1 to: 20 do:' loop but the Morph is not updated during the iterations. I tried 'morph changed' but that doesn't work either. It does work, however, if I fork the animation loop. But than I have an extra process an need Semaphores to wait for its execution. That's not as simple as it could be.

Is there any better way than fork and Semaphore? Maybe some force redraw method I have overlooked?

Thanks in advance!
_______________________________________________
Beginners mailing list
[hidden email]<mailto:[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: Is there an easy way to implement an animation loop?

Karl Ramberg
Ugh, that is right.
Stepping starts right away for a new morph.
Since you want stepping only at certain times you should use startSteppingSelector:  and stopSteppingSelector: (and not call that selector/method #step.)

Karl

On Thu, Jan 5, 2012 at 9:00 PM, Teske, Jan <[hidden email]> wrote:
Thank you, I will try it with stepping. Can you tell my what I have to do to prevent stepping as soon as the Morph is created? A 'morph stopStepping' in the initialize method is not helping since there is no world for the morph at this time. What shall I do instead?

Thanks!
________________________________________
From: [hidden email] [[hidden email]] On Behalf Of karl ramberg [[hidden email]]
Sent: Thursday, January 05, 2012 6:00 PM
To: A friendly place to get answers to even the most basic questions about      Squeak.
Subject: Re: [Newbies] Is there an easy way to implement an animation loop?

Hi
In morphich you should use the step method.

Just add a step method to the morph and start the stepping when you want the animation to start.
I think you must add a self changed or a self layoutChanged at the end of the step method to update the morph.

It's a little more difficult to block all other morphs from update thou.
But if they run animation, you can stop their stepping and start it again when your animation is done.

Morphic runs in a single process and using other processes will not necessarily give trouble.

You set the desired time between steps with method stepTime and return the millisecond time you would like.

Karl

On Thu, Jan 5, 2012 at 2:15 PM, Jan Teske <[hidden email]<mailto:[hidden email]>> wrote:
Hi there,

I try to implement a blocking animation so that the process waits for the animation to be terminated before going ahead. This animation should lower the extent of a Morph in 20 iterations so that it looks like it would shrink.

I tried to accomplish that in a '1 to: 20 do:' loop but the Morph is not updated during the iterations. I tried 'morph changed' but that doesn't work either. It does work, however, if I fork the animation loop. But than I have an extra process an need Semaphores to wait for its execution. That's not as simple as it could be.

Is there any better way than fork and Semaphore? Maybe some force redraw method I have overlooked?

Thanks in advance!
_______________________________________________
Beginners mailing list
[hidden email]<mailto:[hidden email]>
http://lists.squeakfoundation.org/mailman/listinfo/beginners

_______________________________________________
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: Is there an easy way to implement an animation loop?

Bert Freudenberg
On 05.01.2012, at 22:27, karl ramberg wrote:

> Ugh, that is right.
> Stepping starts right away for a new morph.

Only if #wantsSteps answers true.

> Since you want stepping only at certain times you should use startSteppingSelector:  and stopSteppingSelector: (and not call that selector/method #step.)

Or make #wantsSteps answer false and send #startStepping later.

- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners