Welcome Guest ( Log In | Register )




                Web Hosting Guide

 
Reply to this topicNew Topic
Java Mouse Movement.
sparkx
post Sep 14 2008, 04:43 PM
Post #1


Sparkx
Group Icon

Group: [HOSTED]
Posts: 376
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496
myCENTs:55.07


This question is not as easy as you may think to answer, so please read my post completely before replying. 

  I am trying to make an applet that responds to mouse movements but I always have trouble. I can make it work just fine if I find the distance from a point using getX(); or getXOnScreen(); but that's not what I want to do. I want to get the direct input from the mouse. Why? Because when the mouse (cursor) hits the edge of the screen its position stays the same even when you move it. I have tried using a robot to keep the mouse in the center of the screen (setPosition or something like that). But that is just glitch because the robot no longer works when the cursor leaves the window. One possible solution that I haven't gotten to work yet is full screen mode (as in actually full screen not just maximized). This would also solve the problem of accidentally clicking things in the background (not on the game). Any Suggestions?

Please post/link to tutorials, source and/or documentation.

Thanks, 

Sparkx


Go to the top of the page
 
+Quote Post
wutske
post Sep 16 2008, 06:36 PM
Post #2


Way Out Of Control - You need a life :)
Group Icon

Group: [HOSTED]
Posts: 1,267
Joined: 2-August 05
From: Kapellen (Antwerp, Belgium)
Member No.: 7,585
myCENTs:4.00


QUOTE(sparkx @ Sep 14 2008, 06:43 PM) [snapback]128272[/snapback]
This question is not as easy as you may think to answer, so please read my post completely before replying. 

  I am trying to make an applet that responds to mouse movements but I always have trouble. I can make it work just fine if I find the distance from a point using getX(); or getXOnScreen(); but that's not what I want to do. I want to get the direct input from the mouse. Why? Because when the mouse (cursor) hits the edge of the screen its position stays the same even when you move it. I have tried using a robot to keep the mouse in the center of the screen (setPosition or something like that). But that is just glitch because the robot no longer works when the cursor leaves the window. One possible solution that I haven't gotten to work yet is full screen mode (as in actually full screen not just maximized). This would also solve the problem of accidentally clicking things in the background (not on the game). Any Suggestions?

Please post/link to tutorials, source and/or documentation.

Thanks, 

Sparkx


The listner probably receives wrong values when the mouse leaves the screen, see if it throws an error.
Go to the top of the page
 
+Quote Post
sparkx
post Sep 24 2008, 11:25 PM
Post #3


Sparkx
Group Icon

Group: [HOSTED]
Posts: 376
Joined: 11-October 06
From: Dana Point, CA, USA
Member No.: 16,496
myCENTs:55.07


That’s not the problem though... You know when your cursor hits the edge of the screen you can't move it any more? Well that makes a problem for me (because you can continue to move the mouse itself just not the cursor). All I am interested in is the direct input from the mouse not the location of the cursor. I don't want the "coded" input that limits the mouse to inside the screen.

Here is an example... you want to move an object lets say a square that is in the center of the java applet. The applet also has a background image (keep in mind it is all 2d so it is simple). To move the square you would click on it and move the mouse, the background would move the opposite direction of the input from the mouse (giving the affect that the square is moving in that direction but it is not actually moving compared to the screen and centered in the applet). This is simple to do but you quickly run into a problem. The cursor is at the edge of the screen but the square is still not were you want it. See the problem?

Any Suggestions?
Thanks,
Sparkx
Go to the top of the page
 
+Quote Post

Reply to this topicNew Topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Collapse

> Similar Topics

    Topic Title Replies Topic Starter Views Last Action
No New Posts 11 divinity 1,544 4th November 2009 - 12:35 AM
Last post by: HannahI
No New Posts   7 amit nigam 1,198 4th November 2009 - 12:33 AM
Last post by: HannahI
No New Posts   5 sparkx 684 4th November 2009 - 12:29 AM
Last post by: HannahI
No New Posts   6 FearfullyMade 2,863 28th October 2009 - 08:14 PM
Last post by: HannahI
No New Posts   17 vicky99 6,268 17th October 2009 - 11:51 AM
Last post by: surfermac
No New Posts   1 xboxrulz 2,534 8th October 2009 - 04:48 PM
Last post by: iG-steph
No New Posts   5 vicky99 2,115 6th October 2009 - 07:02 AM
Last post by: iG-Daniel
No New Posts   0 starscream 87 24th September 2009 - 12:14 PM
Last post by: starscream
No New Posts   7 suicide 5,069 5th September 2009 - 02:11 PM
Last post by: iG-sam
No New Posts   1 surfermac 242 23rd August 2009 - 09:48 PM
Last post by: yordan
No New Posts   7 Kart 2,624 21st August 2009 - 07:11 PM
Last post by: iG-anon_anon
No New Posts   4 shiv 3,779 19th August 2009 - 01:52 PM
Last post by: iG-Rahul Hanchate
No New Posts   3 thepinder 585 12th August 2009 - 06:32 PM
Last post by: WoodChev
No New Posts   17 mahender 12,605 6th July 2009 - 11:43 AM
Last post by: ashish17
No New Posts   4 hfbvm 728 26th June 2009 - 02:38 PM
Last post by: 100janovski


Web Hosting Powered by ComputingHost.com.