Moving an object inside another object with respective to cursor position

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

Moving an object inside another object with respective to cursor position

mnrao
hi all,
       I have created an rectangle morph and a small ellipse morph. I want to place the ellipse in the rectangle and move the small ellipse(circle) in the direction of the mouse pointer. I want the small ellipse does not come out of the rectangle but small ellipse should be moving with respect to direction of the mouse just as movingeyemorph making the ellipse stay at one place move with in the direction of mouse .can anyone help me make this happen
Reply | Threaded
Open this post in threaded view
|

Re: Moving an object inside another object with respective to cursor position

Bert Freudenberg
On Nov 18, 2006, at 2:54 , mnrao wrote:

>
> hi all,
>        I have created an rectangle morph and a small ellipse morph.  
> I want
> to place the ellipse in the rectangle and move the small ellipse
> (circle) in
> the direction of the mouse pointer. I want the small ellipse does  
> not come
> out of the rectangle but small ellipse should be moving with  
> respect to
> direction of the mouse just as movingeyemorph making the ellipse  
> stay at one
> place move with in the direction of mouse .can anyone help me make  
> this
> happen

You can access the x and y of the mouse pointer in the world's  
viewer. You have access to the x and y and width and height of the  
rectangle, as well as to the width and height of the ellipse. You can  
move the ellipse by setting its x and y. Other than that, it's just  
some math.

- Bert -


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

Re: Moving an object inside another object with respective to cursor position

Andrew Burton-2
Bert Freudenberg wrote:
> Other than that, it's just some math.

For this kind of thing (something like the eyes that follow your mouse)
would it just be math (calculating a certain distance from the center of
the object you're over) or would use an objects "colorUnder" at all?

After playing with "colorUnder" in some experiments last night, I'm
leaning toward math, but I'd prefer to hear it from an expert.  I'd
prefer it so I could also ask: what kind of situation is "colorUnder"
best used for?

--
Andrew Burton
[hidden email]
http://utilitarian.us - A Guide to Esoteric Technology in Paragon City
http://jarodrussell.livejournal.com/ - Take a guess. ;)
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners