[Squeakland] [Q] [eToys] Object under?

Lic. Edgar J. De Cleene edgardec2001 at yahoo.com.ar
Wed Aug 20 09:09:13 UTC 2003


On 19/08/03 18:17, "Karl Ramberg" <karl.ramberg at chello.se> wrote:

> 
> 
> diegogomezdeck at consultar.com wrote:
>> 
>> Hi,
>> 
>> I'd like to get a reference to the morph under the given object.  The same
>> idea behind color-under but with a reference to a morph instead to a color.
>> 
>> Is it possible?
>> 
> At least in 3.6 there is a test called 'overlaps' and it is a very good
> collision detector. You can fx. paint gears that that turn when the
> teeth overlaps the other gears teeth.
> Lots of fun :-)
> 
> Karl
Karl:

You have any code example for having 'gears" in Morphic ? I like to see
that.

Diego:
Lo que sigue es lo que uso en el tren , a lo mejor te sirve.

intersectWhatMorph
    | l |
    l _ ActiveWorld submorphs
                select: [:each | each class == TrackMorph]
                thenCollect: [:m | (self bounds intersects: m bounds)
                        ifTrue: [m]].
    l _ l
                reject: [:any | any == nil].
    ^ l

Thanks  ! Gracias !

edgar



More information about the Squeak-dev mailing list