PDA

View Full Version : Problem making a joystick


Aritz
01-19-2005, 12:23 PM
Hi. Iīm trying to make a joystick. The problem is that when I move the mouse, the checkbutton donīt update the position until the mouse is out the button.

joystick.mcr (http://www.aritzart.com/forums/joystick.mcr)

Thanks and sorry for my english.

Reality3D
01-19-2005, 05:07 PM
Hello Aritz 8):

It's strange that mousemove clausule doesn't work inside a checkbutton(pickbutton or similar). Your only chance is to offset the mouse outside the button a little bit(or maybe Bobo has an smart alternative :)). But then you can't deactivate it :D unless you focus the button with tab and press enter. Anyways, something like this:


-- JOYSTICK
-- by Aritz Aizpurua
-- www.AritzArt.com

macroScript joystick_rollout
category:"AritzTools" buttonText:"Joystick"
toolTip:"Joystick"
(
balioa = [0,0]

rollout joystick_rollout "" width:162 height:162
(
checkbutton jsButton "" pos:[72,72] width:16 height:16

on joystick_rollout mousemove balioa do
(
if jsButton.checked do
(
jsButton.pos=balioa + [-8,8]

)
)
)
createDialog joystick_rollout style:#(#style_titlebar,#Style_toolwindow,#style_sysmenu)
)

Aritz
01-20-2005, 11:24 AM
:D Epa Borja. I have tried the same solution but the result is a little dirty. But now Iīm going to try other solution. Thanks.:buttrock:

Aritz
01-20-2005, 12:55 PM
Another solution:

macroScript JOYSTICK
category:"AritzTools" buttonText:"Joystick"
toolTip:"Joystick"
(
balioa = [0,0]
jscenter = [81,81]
jsactive = False

rollout joystick_rollout "" width:162 height:162
(
button btn0 "" pos:[jscenter.x-9,jscenter.y-9] width:17 height:17
button btn1 "" pos:[jscenter.x-5,jscenter.y-18] width:9 height:9 enabled:false
button btn2 "" pos:[jscenter.x+8,jscenter.y-5] width:9 height:9 enabled:false
button btn3 "" pos:[jscenter.x-5,jscenter.y+8] width:9 height:9 enabled:false
button btn4 "" pos:[jscenter.x-18,jscenter.y-5] width:9 height:9 enabled:false

on btn0 pressed do
(
jsactive = True
btn0.pos = [180,180]
)
on joystick_rollout lbuttondown balioa do
(
jsactive = False
btn0.pos = [jscenter.x-9,jscenter.y-9]
)
on joystick_rollout mousemove balioa do
(
if jsactive == True do
(
jscenter = balioa
btn0.pos = [180,180]
btn1.pos = [jscenter.x-5,jscenter.y-18]
btn2.pos = [jscenter.x+8,jscenter.y-5]
btn3.pos = [jscenter.x-5,jscenter.y+8]
btn4.pos = [jscenter.x-18,jscenter.y-5]
)
)
)
createDialog joystick_rollout style:#(#style_titlebar,#Style_toolwindow,#style_sysmenu)
)

:)

Aritz
01-20-2005, 03:09 PM
Something better :D:

macroScript JOYSTICK
category:"AritzTools" buttonText:"Joystick"
toolTip:"Joystick"
(
balioa = [0,0]
jscenter = [81,81]
jsactive = False

rollout joystick_rollout "" width:162 height:162
(
button btn1 "" pos:[jscenter.x-7,jscenter.y-7] width:15 height:1 enabled:false
button btn2 "" pos:[jscenter.x+7,jscenter.y-7] width:1 height:15 enabled:false
button btn3 "" pos:[jscenter.x-7,jscenter.y+7] width:15 height:1 enabled:false
button btn4 "" pos:[jscenter.x-7,jscenter.y-7] width:1 height:15 enabled:false

button btn0 "" pos:[jscenter.x-7,jscenter.y-7] width:15 height:15

on btn0 pressed do
(
jsactive = True
btn0.pos = [180,180]
)
on joystick_rollout lbuttondown balioa do
(
jsactive = False
btn0.pos = [jscenter.x-7,jscenter.y-7]
)
on joystick_rollout mousemove balioa do
(
if jsactive == True do
(
jscenter = balioa
btn0.pos = [180,180]
btn1.pos = [jscenter.x-7,jscenter.y-7]
btn2.pos = [jscenter.x+7,jscenter.y-7]
btn3.pos = [jscenter.x-7,jscenter.y+7]
btn4.pos = [jscenter.x-7,jscenter.y-7]
)
)
)
createDialog joystick_rollout style:#(#style_titlebar,#Style_toolwindow,#style_sysmenu)
)

Reality3D
01-20-2005, 07:49 PM
One more. Tell me if you like it :P


macroScript joystick_rollout
category:"AritzTools" buttonText:"Joystick"
toolTip:"Joystick"
(
checked = false
deactivated=(bitmap 16 16 color:blue)
activated=(bitmap 16 16 color:red)



rollout joystick_rollout "" width:162 height:162
(

bitmap BitmapImage "" pos:[73,93] width:16 height:16 bitmap:deactivated



on joystick_rollout lbuttondown balioa do
(
--Clicked inside the bitmap button ?
if( balioa.x<=(BitmapImage.pos.x+16) and
balioa.x>=BitmapImage.pos.x and
balioa.y<=(BitmapImage.pos.y+16) and
balioa.y>=BitmapImage.pos.y
) then

(
checked=not checked
if(checked==true) then
(
BitmapImage.bitmap=activated
)
else
(
BitmapImage.bitmap=deactivated
)

)

)
on joystick_rollout mouseMove balioa do
(
if checked do
(
BitmapImage.pos=balioa + [-8,-8]

)
)
) createDialog joystick_rollout
)

Aritz
01-21-2005, 02:30 PM
Thatīs cool! :applause:. even whe can make better looking sliders too.
Now it needs some tweaks to be perfect.
1. Limit button movement in the borders. Adjusting the button borders to the window.
2. When you click the butoon, it takes the mouse position as center, but it would be greater, that the button saves the relative position with the mouse.
3. Click and drag method.
3. xy value visualizer.

Aritz
01-21-2005, 04:24 PM
Do you know if its possible making imagebuttons without borders?

Reality3D
01-21-2005, 05:23 PM
1 2 3 and 3 are possible. Is not possible from what I know to make bitmap buttons without border. You can use imagetag(that have no borders an some great events to handle them) but the same problem of mousemove arise. Maybe there are some ActiveX controllers to do this. By the way, what do you wan't to do with this new "controllers"?

CGTalk Moderation
01-21-2006, 06:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.