Stepping of ImageMorph

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

Stepping of ImageMorph

Hans Gruber
Hi Guys!

An new question von my side again, because I'm quite new in working with Squeak.

I wanted to animate an ImageMorph in my project. Therefore I figured out to overwrite the Morphs step method and set the stepTime. But that was not I was really looking for.
I want to achieve that the ImageMorph switches between several images regarding to the current key which pressed (key event handling is already implemented in my project).

Is there a possibility to start and stop stepping via keystrokes? The next problem would be how to dispatch the different kinds of images changes concerning the current button event.

Do you have any hints for me again?

Regards,
Hans
________________________________________________________________________
Kostenlos tippen, täglich 1 Million gewinnen: zum WEB.DE MillionenKlick!
http://produkte.web.de/go/08/

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

Re: Stepping of ImageMorph

K. K. Subramaniam
On Thursday 14 January 2010 08:41:05 am Hans Gruber wrote:
> An new question von my side again, because I'm quite new in working with
>  Squeak.
If you are new to Squeak, you may want to start with Etoys and create programs
(scripts) visually.
> I wanted to animate an ImageMorph in my project. Therefore I figured out to
>  overwrite the Morphs step method and set the stepTime. But that was not I
>  was really looking for. I want to achieve that the ImageMorph switches
>  between several images regarding to the current key which pressed (key
>  event handling is already implemented in my project).
You could use the typed character as a key into a dictionary of images.

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

Re: Stepping of ImageMorph

Jerome Peace
In reply to this post by Hans Gruber


--- On Wed, 1/13/10, Hans Gruber <[hidden email]> wrote:

> From: Hans Gruber <[hidden email]>
> Subject: [Newbies] Stepping of ImageMorph
> To: [hidden email]
> Date: Wednesday, January 13, 2010, 10:11 PM
> Hi Guys!
>
>An new question von my side again, because I'm quite new in working with Squeak.
>
>I wanted to animate an ImageMorph in my project. Therefore I figured out to overwrite the Morphs step method and set the stepTime. But that was not I was really looking for.

Have you looked at AnimatedImageMorph? To see how it does it?

>I want to achieve that the ImageMorph switches between several images regarding to the current key which pressed (key event handling is already implemented in my project).

You may wish to have an owner morph that receives keystrokes and switches between several animated submorphs.

The best way to program squeak is to think LAZY.

>Is there a possibility to start and stop stepping via keystrokes? The next problem would be how to dispatch the different kinds of images changes concerning the current button event.

The step method could call
self stopStepping
I often use this to create one shot steps.

The part that listens to keystroke could store the keystroke and call startStepping.

Stepping could analyse the keystroke do what is needed and stopStepping after a certain number of steps (you would keep count).

There is also a message called wantsSteps that is queried by the system.
It is also useful to write this method for the morph so that it does not receive steps when it does not want them.

Even after you request stopStepping if you pickup and drop the morph the world will start stepping it again. The only way I've found to prevent this is to have wantsteps to answer false when I really don't want them.

What I did with one morph was to have it recolor itself during its step then stop stepping. When wantsSteps returns true this morph would recolor each time it was dropped .

Assuming you stored the keyStroke in lastKey you would write wantsSteps as
wantsSteps
^ lastKey = onKey .

or something like that.


Yours in curiosity and service, --Jerome Peace


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