|
|
|
|
![]() ![]() |
Sep 14 2008, 04:43 PM
Post
#1
|
|
|
Sparkx Group: [HOSTED] Posts: 366 Joined: 11-October 06 From: Dana Point, CA, USA Member No.: 16,496 myCENTs:44.66 |
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,087 Joined: 2-August 05 From: Kapellen (Antwerp, Belgium) Member No.: 7,585 |
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: 366 Joined: 11-October 06 From: Dana Point, CA, USA Member No.: 16,496 myCENTs:44.66 |
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 |
|
|
|
![]() ![]() |
Similar Topics
|
Lo-Fi Version | Time is now: 5th December 2008 - 12:15 AM |