Squeakland Website
 Forum SubscriptionsForum Subscriptions   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

point towards the mouse?
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Squeakland Forum Index -> Squeakland Community
View previous topic :: View next topic  
Author Message
Bill Kerr
Guest





PostPosted: Wed Nov 11, 2009 2:06 am    Post subject: point towards the mouse? Reply with quote

1) Is it possible to get an arrow to point towards the mouse pointer in etoys?

I can get it to point towards a box which is being moved with the mouse with this script: arrow's heading <-- arrow's bearing to box


In the world menu in the playfield pane there are mouse x and mouse y detectors but arrow's bearing will not accept those detectors as input to replace just the box part


2) I also wanted to detect a mouse click but can't see any way to do that. The input pane in the world menu detects last keystroke but not a mouse click.
Back to top
Hilaire Fernandes
Guest





PostPosted: Wed Nov 11, 2009 2:53 am    Post subject: point towards the mouse? Reply with quote

For point 2., you may have to write the script in Smalltalk mode then
use the code

ActiveHand x to get abscissa of the mouse pointer

Hilaire


2009/11/11 Bill Kerr <billkerr@gmail.com>:
Quote:
1) Is it possible to get an arrow to point towards the mouse pointer in
etoys?
I can get it to point towards a box which is being moved with the mouse with
this script: arrow's heading <-- arrow's bearing to box
In the world menu in the playfield pane there are mouse x and mouse y
detectors but arrow's bearing will not accept those detectors as input to
replace just the box part
2) I also wanted to detect a mouse click but can't see any way to do that.
The input pane in the world menu detects last keystroke but not a mouse
click.
_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland





--
http://blog.ofset.org/hilaire
_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland
Back to top
Hilaire Fernandes
Guest





PostPosted: Wed Nov 11, 2009 3:02 am    Post subject: point towards the mouse? Reply with quote

You may have to write something like that

script1
self
setHeading: (self costume referencePosition bearingToPoint:
ActiveHand x @ ActiveHand y)



This example does not work yet, but you get the idea.

Hilaire



2009/11/11 Hilaire Fernandes <hilaire.fernandes@edu.ge.ch>:
Quote:
For point 2.,  you may have to write the script in Smalltalk mode then
use the code

ActiveHand x to get abscissa of the mouse pointer

Hilaire


2009/11/11 Bill Kerr <billkerr@gmail.com>:
Quote:
1) Is it possible to get an arrow to point towards the mouse pointer in
etoys?
I can get it to point towards a box which is being moved with the mouse with
this script: arrow's heading <-- arrow's bearing to box
In the world menu in the playfield pane there are mouse x and mouse y
detectors but arrow's bearing will not accept those detectors as input to
replace just the box part
2) I also wanted to detect a mouse click but can't see any way to do that.
The input pane in the world menu detects last keystroke but not a mouse
click.
_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland





--
http://blog.ofset.org/hilaire




--
http://blog.ofset.org/hilaire
_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland
Back to top
Darius Clarke
Guest





PostPosted: Wed Nov 11, 2009 3:03 am    Post subject: point towards the mouse? Reply with quote

For point 1 you can use the slope formula m = (y1-y2)/(x1-x2) and then arcTan m to get degrees. 

arcTan may have to come from Smalltalk mode. 

Cheers,
Darius

On Tue, Nov 10, 2009 at 10:53 PM, Hilaire Fernandes <hilaire.fernandes@edu.ge.ch (hilaire.fernandes@edu.ge.ch)> wrote:
Quote:
For point 2.,  you may have to write the script in Smalltalk mode then
use the code

ActiveHand x to get abscissa of the mouse pointer

Hilaire


2009/11/11 Bill Kerr <billkerr@gmail.com (billkerr@gmail.com)>:

Quote:
1) Is it possible to get an arrow to point towards the mouse pointer in
etoys?
I can get it to point towards a box which is being moved with the mouse with
this script: arrow's heading <-- arrow's bearing to box
In the world menu in the playfield pane there are mouse x and mouse y
detectors but arrow's bearing will not accept those detectors as input to
replace just the box part
2) I also wanted to detect a mouse click but can't see any way to do that.
The input pane in the world menu detects last keystroke but not a mouse
click.


Quote:
_______________________________________________
squeakland mailing list
squeakland@squeakland.org (squeakland@squeakland.org)
http://lists.squeakland.org/mailman/listinfo/squeakland





--
http://blog.ofset.org/hilaire
_______________________________________________
squeakland mailing list
squeakland@squeakland.org (squeakland@squeakland.org)
http://lists.squeakland.org/mailman/listinfo/squeakland
Back to top
Hilaire Fernandes
Guest





PostPosted: Wed Nov 11, 2009 3:34 am    Post subject: point towards the mouse? Reply with quote

I was meaning point1

Hilaire

2009/11/11 Hilaire Fernandes <hilaire.fernandes@edu.ge.ch>:
Quote:
For point 2.,  you may have to write the script in Smalltalk mode then
use the code

ActiveHand x to get abscissa of the mouse pointer
_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland
Back to top
Bill Kerr
Guest





PostPosted: Wed Nov 11, 2009 5:38 am    Post subject: point towards the mouse? Reply with quote

On Wed, Nov 11, 2009 at 7:32 PM, Scott Wallace <scott.wallace@squeakland.org (scott.wallace@squeakland.org)> wrote:
Quote:
On Nov 10, 2009, at 11:02 PM, Darius Clarke wrote:

Quote:
For point 1 you can use the slope formula m = (y1-y2)/(x1-x2) and then arcTan m to get degrees.

arcTan may have to come from Smalltalk mode.

Cheers,
Darius

On Tue, Nov 10, 2009 at 10:53 PM, Hilaire Fernandes <hilaire.fernandes@edu.ge.ch (hilaire.fernandes@edu.ge.ch)> wrote:
For point 2.,  you may have to write the script in Smalltalk mode then
use the code

ActiveHand x to get abscissa of the mouse pointer

Hilaire


2009/11/11 Bill Kerr <billkerr@gmail.com (billkerr@gmail.com)>:
Quote:
1) Is it possible to get an arrow to point towards the mouse pointer in
etoys?



FWIW I attach a working example... notice that it's all done with tiles -- no textual scripting.




wonderful answers, thanks all
Back to top
p.a.dreyfuss@excite.com
Guest





PostPosted: Wed Nov 11, 2009 5:39 am    Post subject: point towards the mouse? Reply with quote

Hi,Bill

You'll find the tiles mouseX and mouseY in the playfield category of a playfield or of the world.

get an arrow fom object catalog/graphics

move the ble rotation handle sligtly to make te center or rotation visible and move it shift/drag to the foot of the arrow.
get the viewer of the arrow category polygon, et the arrow's vertex .cursor to 2 (head of the arrow).

now just build the tiles :

arrow's x at cursor _ playfield's mousex
arrow's y at cursor _ playfield's mousey

You probably just need to find where the tiles mouse and mousey were lying, but this will help other people.

Regards


-----Original Message-----
From: "Hilaire Fernandes" [hilaire.fernandes@edu.ge.ch]
Date: 11/11/2009 02:51 AM
To: "Bill Kerr" <billkerr@gmail.com>
CC: "squeakland.org mailing list" <squeakland@squeakland.org>
Subject: Re: [squeakland] point towards the mouse?

You may have to write something like that

script1
self
setHeading: (self costume referencePosition bearingToPoint:
ActiveHand x @ ActiveHand y)



This example does not work yet, but you get the idea.

Hilaire



2009/11/11 Hilaire Fernandes <hilaire.fernandes@edu.ge.ch>:
Quote:
For point 2.,  you may have to write the script in Smalltalk mode then
use the code

ActiveHand x to get abscissa of the mouse pointer

Hilaire


2009/11/11 Bill Kerr <billkerr@gmail.com>:
Quote:
1) Is it possible to get an arrow to point towards the mouse pointer in
etoys?
I can get it to point towards a box which is being moved with the mouse with
this script: arrow's heading <-- arrow's bearing to box
In the world menu in the playfield pane there are mouse x and mouse y
detectors but arrow's bearing will not accept those detectors as input to
replace just the box part
2) I also wanted to detect a mouse click but can't see any way to do that.
The input pane in the world menu detects last keystroke but not a mouse
click.
_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland





--
http://blog.ofset.org/hilaire




--
http://blog.ofset.org/hilaire
_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland


Earn your MBA from Regis University, 100% online. Free info packs! Regis University MBA Click Here For More Information
Back to top
Bill Kerr
Guest





PostPosted: Wed Nov 11, 2009 6:21 am    Post subject: point towards the mouse? Reply with quote

On Wed, Nov 11, 2009 at 8:38 PM, Scott Wallace <scott.wallace@squeakland.org (scott.wallace@squeakland.org)> wrote:
Quote:
Attached below is another solution, using an invisible "sprite".


How did you make the invisible sprite Scott?
I just clicked on your Sprite's show key and nothing appeared
Is it just an empty drawing which you keep? I haven't tried that yet


I almost worked out that one myself after my intial post
But I made a visible sprite and then shrunk it - it sort of worked but because the sprite was visible once it was ticking I couldn't use the mouse to switch off the clock or anything else because the sprite got in the way
 
Quote:

 -- Scott








On Nov 11, 2009, at 1:02 AM, Scott Wallace wrote:

Quote:
On Nov 10, 2009, at 11:02 PM, Darius Clarke wrote:

Quote:
For point 1 you can use the slope formula m = (y1-y2)/(x1-x2) and then arcTan m to get degrees.

arcTan may have to come from Smalltalk mode.

Cheers,
Darius

On Tue, Nov 10, 2009 at 10:53 PM, Hilaire Fernandes <hilaire.fernandes@edu.ge.ch (hilaire.fernandes@edu.ge.ch)> wrote:
For point 2.,  you may have to write the script in Smalltalk mode then
use the code

ActiveHand x to get abscissa of the mouse pointer

Hilaire


2009/11/11 Bill Kerr <billkerr@gmail.com (billkerr@gmail.com)>:
Quote:
1) Is it possible to get an arrow to point towards the mouse pointer in
etoys?


FWIW I attach a working example... notice that it's all done with tiles -- no textual scripting.

-- Scott


<pointTowardCursor.002.pr>_______________________________________________
squeakland mailing list
squeakland@squeakland.org (squeakland@squeakland.org)
http://lists.squeakland.org/mailman/listinfo/squeakland


_______________________________________________
squeakland mailing list
squeakland@squeakland.org (squeakland@squeakland.org)
http://lists.squeakland.org/mailman/listinfo/squeakland

Back to top
rita
member


Joined: 04 Oct 2004
Posts: 47

PostPosted: Wed Nov 11, 2009 6:35 am    Post subject: point towards the mouse? Reply with quote

Scott Wallace wrote:
Quote:
Attached below is another solution, using an invisible "sprite".

Scott, it is great that you uploaded the projects with your solution to
the showcase! This is a great way to keep ideas like this and make it
available for everyone.

Rita
Quote:
-- Scott


------------------------------------------------------------------------






On Nov 11, 2009, at 1:02 AM, Scott Wallace wrote:


Quote:
On Nov 10, 2009, at 11:02 PM, Darius Clarke wrote:


Quote:
For point 1 you can use the slope formula m = (y1-y2)/(x1-x2) and then arcTan m to get degrees.

arcTan may have to come from Smalltalk mode.

Cheers,
Darius

On Tue, Nov 10, 2009 at 10:53 PM, Hilaire Fernandes <hilaire.fernandes@edu.ge.ch> wrote:
For point 2., you may have to write the script in Smalltalk mode then
use the code

ActiveHand x to get abscissa of the mouse pointer

Hilaire


2009/11/11 Bill Kerr <billkerr@gmail.com>:

Quote:
1) Is it possible to get an arrow to point towards the mouse pointer in
etoys?

FWIW I attach a working example... notice that it's all done with tiles -- no textual scripting.

-- Scott


<pointTowardCursor.002.pr>_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland

------------------------------------------------------------------------

_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland


--
Rita Freudenberg
Squeakland Foundation
http://www.squeakland.org

_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland
Back to top
View user's profile Send private message
scott
enthusiast


Joined: 05 May 2003
Posts: 235
Location: Palo Alto, California

PostPosted: Wed Nov 11, 2009 6:42 am    Post subject: point towards the mouse? Reply with quote

On Nov 11, 2009, at 2:20 AM, Bill Kerr wrote:

Quote:
On Wed, Nov 11, 2009 at 8:38 PM, Scott Wallace <scott.wallace@squeakland.org> wrote:
Quote:
Attached below is another solution, using an invisible "sprite".

How did you make the invisible sprite Scott?
I just clicked on your Sprite's show key and nothing appeared
Is it just an empty drawing which you keep? I haven't tried that yet

I almost worked out that one myself after my intial post
But I made a visible sprite and then shrunk it - it sort of worked but because the sprite was visible once it was ticking I couldn't use the mouse to switch off the clock or anything else because the sprite got in the way

Heh, heh... The sprite is a tiny RectangleMorph, which is:

(a) Invisible -- color transparent, borderWidth 0.
(b) Locked -- so that the sprite doesn't get in the way of mouse use.

-- Scott_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland
Back to top
View user's profile Send private message
Bill Kerr
Guest





PostPosted: Wed Nov 11, 2009 6:59 am    Post subject: point towards the mouse? Reply with quote

On Wed, Nov 11, 2009 at 8:09 PM, p.a.dreyfuss@excite.com (p.a.dreyfuss@excite.com) <p.a.dreyfuss@excite.com (p.a.dreyfuss@excite.com)> wrote:
Quote:

Hi,Bill

You'll find the tiles mouseX and mouseY in the playfield category of a playfield or of the world.

get an arrow fom object catalog/graphics

move the ble rotation handle sligtly to make te center or rotation visible and move it shift/drag to the foot of the arrow.
get the viewer of the arrow category polygon, et the arrow's vertex .cursor to 2 (head of the arrow).

now just build the tiles :

arrow's x at cursor _ playfield's mousex
arrow's y at cursor _ playfield's mousey

You probably just need to find where the tiles mouse and mousey were lying, but this will help other people.


I've had a go at your instructions Pierre and learnt a few new things but haven't been totally successful with the pointing
btw I just wanted pointing at this stage not moving to the mouse as well
a worked example would be great if you have the time
regards
Back to top
Bill Kerr
Guest





PostPosted: Wed Nov 11, 2009 7:14 am    Post subject: point towards the mouse? Reply with quote

On Wed, Nov 11, 2009 at 9:11 PM, Scott Wallace <scott.wallace@squeakland.org (scott.wallace@squeakland.org)> wrote:
Quote:
On Nov 11, 2009, at 2:20 AM, Bill Kerr wrote:

Quote:
On Wed, Nov 11, 2009 at 8:38 PM, Scott Wallace <scott.wallace@squeakland.org (scott.wallace@squeakland.org)> wrote:
Quote:
Attached below is another solution, using an invisible "sprite".

How did you make the invisible sprite Scott?
I just clicked on your Sprite's show key and nothing appeared
Is it just an empty drawing which you keep? I haven't tried that yet

I almost worked out that one myself after my intial post
But I made a visible sprite and then shrunk it - it sort of worked but because the sprite was visible once it was ticking I couldn't use the mouse to switch off the clock or anything else because the sprite got in the way


Heh, heh...  The sprite is a tiny RectangleMorph, which is:

(a)  Invisible -- color transparent, borderWidth 0.
(b)  Locked -- so that the sprite doesn't get in the way of mouse use.


thanks


btw if you close the viewer of an invisible sprite is it possible to get it back?


I had that problem last week when a student was making a lunar lander disappear by hiding it
then he inadvertently closed the viewer and we couldn't work out how to get it back so he lost his work
 
Quote:

 -- Scott_______________________________________________

squeakland mailing list
squeakland@squeakland.org (squeakland@squeakland.org)
http://lists.squeakland.org/mailman/listinfo/squeakland


Back to top
Hilaire Fernandes
Guest





PostPosted: Wed Nov 11, 2009 8:58 am    Post subject: point towards the mouse? Reply with quote

Shift-clic in the background display a menu with the list of morh ?

Hilaire

2009/11/11 Bill Kerr <billkerr@gmail.com>:
Quote:
btw if you close the viewer of an invisible sprite is it possible to get it
back?
I had that problem last week when a student was making a lunar lander
disappear by hiding it
then he inadvertently closed the viewer and we couldn't work out how to get
it back so he lost his work
_______________________________________________
squeakland mailing list
squeakland@squeakland.org
http://lists.squeakland.org/mailman/listinfo/squeakland
Back to top
Bert
kahuna


Joined: 12 May 2003
Posts: 1010
Location: Magdeburg, Germany

PostPosted: Wed Nov 11, 2009 11:54 am    Post subject: point towards the mouse? Reply with quote

On 11.11.2009, at 12:13, Bill Kerr wrote:
Quote:
On Wed, Nov 11, 2009 at 9:11 PM, Scott Wallace <scott.wallace@squeakland.org (scott.wallace@squeakland.org)> wrote:
Quote:
On Nov 11, 2009, at 2:20 AM, Bill Kerr wrote:

Quote:
On Wed, Nov 11, 2009 at 8:38 PM, Scott Wallace <scott.wallace@squeakland.org (scott.wallace@squeakland.org)> wrote:
Quote:
Attached below is another solution, using an invisible "sprite".

How did you make the invisible sprite Scott?
I just clicked on your Sprite's show key and nothing appeared
Is it just an empty drawing which you keep? I haven't tried that yet

I almost worked out that one myself after my intial post
But I made a visible sprite and then shrunk it - it sort of worked but because the sprite was visible once it was ticking I couldn't use the mouse to switch off the clock or anything else because the sprite got in the way


Heh, heh... The sprite is a tiny RectangleMorph, which is:

(a) Invisible -- color transparent, borderWidth 0.
(b) Locked -- so that the sprite doesn't get in the way of mouse use.


thanks


btw if you close the viewer of an invisible sprite is it possible to get it back?


I had that problem last week when a student was making a lunar lander disappear by hiding it
then he inadvertently closed the viewer and we couldn't work out how to get it back so he lost his work




Use the "Players" tool from the supplies flap.


Instead of a transparent rectangle you also can just use a small sketch and click its "hide" tile (and e.g. make buttons to show and hide for debugging).

- Bert -
Back to top
View user's profile Send private message
Bill Kerr
Guest





PostPosted: Sun Nov 15, 2009 6:43 am    Post subject: point towards the mouse? Reply with quote

On Thu, Nov 12, 2009 at 2:54 AM, Bert Freudenberg <bert@freudenbergs.de (bert@freudenbergs.de)> wrote:
Quote:
Ah, I found your blog entry now. Attached is a project that I think does what you wanted - I did not hide the dots, would be simple though.

This task is a bit geared towards Scratch - it's more complicated in Etoys as there is no reification of the mouse pointer. Might be a nice idea to make a player for it though ...




Nice project Bert, thanks


In reconstructing what you did I found out
1) that if I put the mouseDown script (click script) that moves the target object to the mouse object into the target script then it didn't work, it required a world script - not sure whether that is a bug or a feature (that you need a world script to detect a click on the world)


2) this line was tricky to build:
arrow's distance to target > 20
(a) ie. I found arrow's distance to dot in the observation pane and replaced the dot with a target - but then there were no option for a > extension
At that stage I would have given up but since you had done it then it had to be possible
(b) So I then found an arrow's distance with an assignment handle in the geometry pane and then found I could replace the arrow's distance part with the arrow's distance to target built in (a)
 
Quote:

- Bert -
Back to top
Display posts from previous:   
Post new topic   Reply to topic    Squeakland Forum Index -> Squeakland Community All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group