[Newbies] Morphic - how to make a submorph not visible outside his
owner ?
patrick dudjalija
patrick.dudjalija at gmail.com
Wed Jul 18 10:27:07 UTC 2012
Hi everyone !
I'm playing around with horizontal scrolling of a submorph into a morph.
Let's take a simple horizontal scrolling to the left.
When the submorph is getting out of the left side of the morph, it should
reappear to the right side of the morph.
The problem is that during the "transition" the submorph is still visible
outside of the morph.
So, I'm searching for a solution for the submorph not being visible outside
the bounds of it's owner.
To visualize the problem, see code below.
(for an obscure reason, the transcript window must be opened, but that's
not the point).
Thanks a lot for your help !!!!
Here is the sample code (don't forget to open the transcript window):
|m1 m2|
m1:=Morph new.
m1 extent:800 at 600.
m1 color:Color blue.
m1 center: Display center.
m1 openInWorld.
m2:=Morph new.
m2 extent:200 at 200.
m2 color:Color red.
m1 addMorph: m2.
m2 center: m1 center.
1 to:200 do:[:el|
|pos|
(Duration seconds:0.01) asDelay wait.
pos:=(m2 position x -5)@(m2 position y).
((pos x + m2 width) >= (m1 position x)) ifFalse:[
pos:=((m1 position x + m1 width)@ m2 position y).
].
Transcript show: (pos asString);cr.
m2 position:pos.
].
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/beginners/attachments/20120718/b3bf0bde/attachment.htm
More information about the Beginners
mailing list