简体   繁体   中英

Squeak-Smalltalk: Draw lines in Morph

I need to draw lines in a Morph, or at least I think I do. I managed to draw colored lines in a Form, so putting the Form inside a Morph should be fine as well, if that is even possible. How do I go about this?

I'm actually just trying to find a way to be able to draw graphics for a simple game while reacting to keyboard input. Keyboard input seems to be doable using a Morph, but now I'm stuck and I can't seem to find any examples doing anything like I want. Frankly, I find the lack of documentation disturbing.

Please have a look at the book "Squeak by Example" (Black et al.), especially the chapter "Creating and drawing your own morphs". It is available here, for example: https://hal.inria.fr/inria-00441576/file/SBE.pdf

If you have a Form already, you can use ImageMorph to display the Form. Class comment:

ImageMorph is a morph that displays a picture (Form). My extent is determined by the extent of my form.

Use #image: to set my picture.

You can compose Morphs with addMorph: and friends, if you want to attach your image somewhere.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM