Page 1 of 1
How to build a 360 degree angle finder
Posted: Mon Mar 28, 2016 9:52 am
by samjith
Hi,
Is there any way to build a angle finder by user interface itself. Plz find the attachment.
i can't able to rotate the needle handle.
is there any way to disable its 3D view?
Actually i need is that, i can able to rotate the handle inside this circle (mouse down) like a minute handle in a clock and show the current angle when mouse up.
Re: How to build a 360 degree angle finder
Posted: Wed Apr 13, 2016 11:11 am
by MaxV
This is the code for a rotating graphic:
Code: Select all
on MouseMove
if the muovi of me then
put the loc of me into centro
put the mouseLoc into mymouse
put (item 1 of mymouse) - (item 1 of centro) into dX
put (item 2 of mymouse) - (item 2 of centro) into dY
if dx = 0 then
put 90
else
if dX > 0 then
set the angle of me to -1 * ( -1 * 360 / (2 * pi ) * atan(dY/dx))
else
set the angle of me to -1 * ( -1 * 360 / (2 * pi ) * atan(dY/dx) + 180 )
end if
end if
end if
end MouseMove
on MouseDown
set the muovi of me to true
end MouseDown
on MouseUp
set the muovi of me to false
end MouseUp
Re: How to build a 360 degree angle finder
Posted: Wed Apr 13, 2016 11:18 am
by Klaus
Hi firends,
maybe you didn't know, but the "mousemove" message comes with 2 parameters,
the current X and Y position of the mouse!
So you can shorten this script and also make it a bit more efficient:
Code: Select all
on MouseMove X,Y
if the muovi of me then
put the loc of me into centro
## put the mouseLoc into mymouse
## put (item 1 of mymouse) - (item 1 of centro) into dX
## put (item 2 of mymouse) - (item 2 of centro) into dY
put X - (item 1 of centro) into dX
put Y - (item 2 of centro) into dY
...
Best
Klaus