|
|
|
| Web Hosting Guide |
![]() ![]() |
Java Mouse Movement. |
Sep 14 2008, 04:43 PM
Post
#1
|
|
|
Sparkx 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 |
|
|
|
Sep 16 2008, 06:36 PM
Post
#2
|
|
|
Way Out Of Control - You need a life :) 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. |
|
|
|
Sep 24 2008, 11:25 PM
Post
#3
|
|
|
Sparkx 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 |
|
|
|
![]() ![]() |
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
Similar Topics
| Topic Title | Replies | Topic Starter | Views | Last Action | |||
|---|---|---|---|---|---|---|---|
![]() |
11 | divinity | 1,544 | 4th November 2009 - 12:35 AM Last post by: HannahI |
|||
![]() |
7 | amit nigam | 1,198 | 4th November 2009 - 12:33 AM Last post by: HannahI |
|||
![]() |
5 | sparkx | 684 | 4th November 2009 - 12:29 AM Last post by: HannahI |
|||
![]() |
6 | FearfullyMade | 2,863 | 28th October 2009 - 08:14 PM Last post by: HannahI |
|||
![]() |
17 | vicky99 | 6,268 | 17th October 2009 - 11:51 AM Last post by: surfermac |
|||
![]() |
1 | xboxrulz | 2,534 | 8th October 2009 - 04:48 PM Last post by: iG-steph |
|||
![]() |
5 | vicky99 | 2,115 | 6th October 2009 - 07:02 AM Last post by: iG-Daniel |
|||
![]() |
0 | starscream | 87 | 24th September 2009 - 12:14 PM Last post by: starscream |
|||
![]() |
7 | suicide | 5,069 | 5th September 2009 - 02:11 PM Last post by: iG-sam |
|||
![]() |
1 | surfermac | 242 | 23rd August 2009 - 09:48 PM Last post by: yordan |
|||
![]() |
7 | Kart | 2,624 | 21st August 2009 - 07:11 PM Last post by: iG-anon_anon |
|||
![]() |
4 | shiv | 3,779 | 19th August 2009 - 01:52 PM Last post by: iG-Rahul Hanchate |
|||
![]() |
3 | thepinder | 585 | 12th August 2009 - 06:32 PM Last post by: WoodChev |
|||
![]() |
17 | mahender | 12,605 | 6th July 2009 - 11:43 AM Last post by: ashish17 |
|||
![]() |
4 | hfbvm | 728 | 26th June 2009 - 02:38 PM Last post by: 100janovski |
|||
|
Lo-Fi Version | Time is now: 8th November 2009 - 06:31 PM |
© 2009 AstaHost: Free Web Hosting & Technical Discussion, Free Web Hosting. a member of xisto.
Powered by Invision Board. Skin: IPB Forum Skins
Expand / Collapse Navigation



Sep 14 2008, 04:43 PM




