Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (495)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Mouse Motion from anywhere  (Read 1919 times)
0 Members and 1 Guest are viewing this topic.
Offline Malohkan

Senior Member




while (true) System.out.println("WOO!!!!");


« Posted 2005-04-06 01:36:39 »

I want to know where my mouse is everywhere, even if it's not over my window.  I want to know where the mouse is in global coords no matter what.  The MouseMotionListener interface only let's me know where the mouse is if it's hovering over my window.  Any ideas?

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline weston

Junior Member





« Reply #1 - Posted 2005-04-06 03:29:10 »

you could find the amount of change in the mouse's position and find the global coordinates from there. This means you keep track of some mousePosition variable in your game instead of using the mouse's actual position. If you want to do this, you should hide the mouse for one, but will also need to reset the mouse position to the center after you find out how much it changed.

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
Offline Malohkan

Senior Member




while (true) System.out.println("WOO!!!!");


« Reply #2 - Posted 2005-04-06 19:54:23 »

ehh I think you misunderstood my question.  I don't want to limit the movement of the mouse, I want to monitor it.  As of right now, I can move my mouse all over the screen and my mouseMoved() method will never be called unless the motion occured directly over my window.  I want to be able to monitor mouse motion over the entire screen.

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline weston

Junior Member





« Reply #3 - Posted 2005-04-06 20:07:30 »

I understand what your looking for and my solution would give it. I think the part that I missed is that you actually want the mouse to leave the window, I figured that was a negative effect of the program.

heres a code example of what I was describing:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
public class AClass implements MouseMotionListener
{
      private int mouseX;
      private int mouseY;
      private int screenCenterX;
      private int screenCenterY;
     
      public AClass()
      {
            mouseX = getMouseX();
            mouseY = getMouseY();
           
            screenCenterX = getScreenWidth()/2;
            screenCenterY = getScreenHeight()/2;
      }

      public void mouseMoved(MouseEvent e)
      {
            int dx = screenCenterX-lastX;
            int dy = screenCenterY-lastY;

            mouseX += dx;
            mouseY += dy;

            //use java.awt.Robot to move the mouse to
           //screenCenterX/screenCenterY
     }
}


edit: added the code.

for(int i = 1; i > 0; i++)
{
System.out.println(i+" cups of java downed");
}
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #4 - Posted 2005-04-06 20:47:30 »

As far as I know... it's not possible. You can only track movements above your components and movements outside of those components is only possible if it's a dragging motion, which started inside one of your components.

弾幕 ☆ @mahonnaiseblog
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #5 - Posted 2005-04-07 02:19:39 »

There's the java.awt.MouseInfo class, added in 1.5. It allows you to get the location of the mouse pointer anywhere on the screen.

Thanks,
 Dmitri
Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #6 - Posted 2005-04-07 06:07:27 »

Is there somewhere a list with classes and methods which were added in 1.5?

弾幕 ☆ @mahonnaiseblog
Offline Malohkan

Senior Member




while (true) System.out.println("WOO!!!!");


« Reply #7 - Posted 2005-04-07 11:24:33 »

Weston, in your code, you keep the mouse contained at the center of the screen.  Like I said, I don't want to manipulate it, I want to monitor it.  With your code the mouse can't even leave my window unless I move the mouse really fast at one point in which case the mouseMoved() method would not be called again no matter how I move the mouse until I move it back over my window where it would be re-locked at the center.

I'll check out the new MouseInfo class, thanks!  As this is just for personal use I have no problems with playing with 1.5 classes Smiley

Admin and Game Developer at
GameLizard.com
Play Rimscape!    |    Play Conquer!
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #8 - Posted 2005-04-07 18:53:58 »

Quote
Is there somewhere a list with classes and methods which were added in 1.5?


Unfortunately, I don't think so, although I think it'd be quite useful.

A good place to start would be the ReleaseNotes, and if you know
the area you're interested in (awt in this case), you could get to
 http://java.sun.com/j2se/1.5.0/docs/guide/awt/1.5/index.html

Thanks,
 Dmitri

Offline oNyx

JGO Coder


Medals: 2


pixels! :x


« Reply #9 - Posted 2005-04-08 01:54:38 »

A "diff doc" could be generated automatically. All you need is creating a tree with class names and their method signatures... hmm... maybe I'll do something like that one day (if my todo list ever gets empty Wink).

Well, I know where the docs are. I'm using the api-bot¹ almost each day Smiley

[¹ It's a quakenet bot, which can be querried for the docs of classes/methods by writing those names (you can also use wildcards). It's pretty handy.]

弾幕 ☆ @mahonnaiseblog
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline trembovetski

Senior Member




If only I knew what I'm talking about!


« Reply #10 - Posted 2005-04-08 03:59:46 »

Well, the thing is, I'm sure these diffs (or some kind of their equivalent) exist somewhere. For example, SQE and JCK folks need to check that no new apis could be sneaked into a new release..

I'll ask around..

Dmitri
Offline tonberry1

Junior Member





« Reply #11 - Posted 2005-04-11 11:13:22 »

Quote
A good place to start would be the ReleaseNotes,

Maybe a little better link (the subject list):
http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html

-= Life is what you decide it to be - Solid Snake =-
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Dwinin (23 views)
2014-09-12 09:08:26

Norakomi (56 views)
2014-09-10 13:57:51

TehJavaDev (69 views)
2014-09-10 06:39:09

Tekkerue (34 views)
2014-09-09 02:24:56

mitcheeb (56 views)
2014-09-08 06:06:29

BurntPizza (40 views)
2014-09-07 01:13:42

Longarmx (26 views)
2014-09-07 01:12:14

Longarmx (33 views)
2014-09-07 01:11:22

Longarmx (31 views)
2014-09-07 01:10:19

mitcheeb (39 views)
2014-09-04 23:08:59
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!