Stop the cursor from leaving the frame/panel?
Im making a simple target game where you shoot targets with the mouse. What I'd like to do is stop the mouse cursor from leaving the panel/frame. I've tried moving the cursor there with the Robot class, but 1) it doesnt lock it directly to the edge, 2) it doesnt stop at the top edge and left edge, 3) the bottom edge results in the cursor being placed in the wrong place and finally, 4) if u move the cursor fast enough it breaks out anyway :(
Hope someone can help,
Thanx.
You shall have to check the x and y coordinates and see if it gets out of the boundary of the Frame/Panel.And restrict the same.
would you like to show up your Mobile/Java games and code up in this site
http://www.ideas2work.com
Regards,
Istiaque.
http://www.ideas2work.com
Wow nice responses. I have two questions:1) What is native code?2) Is it difficult to make it full screen? I was thinking of doing that but the thought of rescaling everything (i.e. fonts, images etc) made me think otherwise.Thanx,Jon
> Wow nice responses. I have two questions:
>
> 1) What is native code?
Write the code to capture the mouse in C/C++ (Windows supports capturing the mouse cursor - dunno about linux or solaris), then write a JNI wrapper function so you can call it from within Java.
>
> 2) Is it difficult to make it full screen? I was
> thinking of doing that but the thought of rescaling
> everything (i.e. fonts, images etc) made me think
> otherwise.
Fullscreen is easy, simply graphicsDevice.setFullscreenWindow(window);
Once in fullscreen, you can change the resolution to whatever you like (limited to what is supported by the gfx card ofcourse :p), so you shouldn't have to worry about rescaling gfx 2much.
>
> Thanx,
> Jon