Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (516)
Games in Android Showcase (123)
games submitted by our members
Games in WIP (577)
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  
  tracking mouse when its outside the applet window without using jinput  (Read 1821 times)
0 Members and 1 Guest are viewing this topic.
Offline rouncer

Junior Duke





« Posted 2010-04-29 13:07:10 »

Is this even possible?  Cause in my game you control your shield and sword with the mouse and the mouse only activating when its in the applet window is a complete disaster.
Why didnt they implement "x moved difference" instead of "x absolute coordinate" cause thats what I need!
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #1 - Posted 2010-04-29 13:15:24 »

you can use AWT's MouseInfo for this

http://java.sun.com/j2se/1.5.0/docs/api/java/awt/MouseInfo.html
Offline CommanderKeith
« Reply #2 - Posted 2010-04-29 13:28:51 »

Interesting, I never knew that class existed  Cool

I wonder if getPointerInfo()  throws a security exception by default... i'll test it when I'm home

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline rouncer

Junior Duke





« Reply #3 - Posted 2010-04-29 13:30:22 »

Cool thanks, that works.

I cleared up a bug with that too!

Only problem is I cant get the mouse "vectors" all this means is when the mouse scrolls to the side of the screen id like it to still keep on reading mouse movement, cause if I dont when the mouse reaches the end of the screen the shield will stop moving around the character even if you meant for the character to keep shifting the shield across, its just that you've hit the side of the screen and its stopped moving, even though your still moving the mouse!

Like at the moment, to get mouse vectors I am comparing the old mouse position to the new one, but when it hits the side of the screen it stops working...

Is there a way around this?

I dont really mind the security warning, cause jinput needs it to so theres no way around it.
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #4 - Posted 2010-04-29 13:31:29 »

Interesting, I never knew that class existed  Cool

I wonder if getPointerInfo()  throws a security exception by default... i'll test it when I'm home

It better throw one otherwise something is broken Smiley
Offline kappa
« League of Dukes »

JGO Kernel


Medals: 78
Projects: 15


★★★★★


« Reply #5 - Posted 2010-04-29 13:38:39 »

Cool thanks, that works.

I cleared up a bug with that too!

Only problem is I cant get the mouse "vectors" all this means is when the mouse scrolls to the side of the screen id like it to still keep on reading mouse movement, cause if I dont when the mouse reaches the end of the screen the shield will stop moving around the character even if you meant for the character to keep shifting the shield across, its just that you've hit the side of the screen and its stopped moving, even though your still moving the mouse!

Like at the moment, to get mouse vectors I am comparing the old mouse position to the new one, but when it hits the side of the screen it stops working...

Is there a way around this?

personally I think your approaching this problem wrong, you shouldn't really need to jump all these hoops to get decent game controls, plenty of other games do it fine without all this extra stuff. Instead I recommend that you grab the mouse and release it when its not absolutely needed.
Offline rouncer

Junior Duke





« Reply #6 - Posted 2010-04-29 13:51:43 »

For the style of game im making I need this, its how the whole idea works.

If I was just happy with keyboard controls, and I was making a simple hack at the enemy combat game then I probably wouldnt need to go to the trouble, but im writing a combat "sim" and I need mouse controls for the arms of the character.
I dont want to have to change my idea just because im using java.

I spose jinput probably could do it so ill just learn that.
Offline rouncer

Junior Duke





« Reply #7 - Posted 2010-04-29 13:57:21 »

Hang on, Ive got another idea...  What if I continually set the mouse position to the centre of the screen?  Can I do that??
Offline CommanderKeith
« Reply #8 - Posted 2010-04-29 14:01:20 »

Mouse drags keep coming even when the cursor is outside of the frame (and probably applet). Maybe use mouse drags?

It better throw one otherwise something is broken Smiley

I suppose, but I can't think of a program that uses a graphical interface with number button on the screen to enter a PIN code   Tongue

Hang on, Ive got another idea...  What if I continually set the mouse position to the centre of the screen?  Can I do that??
java.awt.Robot can do that, and LWJGL has some methods to do that too. Both require full security priveleges

Offline rouncer

Junior Duke





« Reply #9 - Posted 2010-04-29 14:47:57 »

Thanks Commander Keith.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Nate

JGO Kernel


Medals: 153
Projects: 4
Exp: 14 years


Esoteric Software


« Reply #10 - Posted 2010-04-30 00:48:40 »

+1 to grab the mouse.

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.

TehJavaDev (33 views)
2014-10-27 03:28:38

TehJavaDev (26 views)
2014-10-27 03:27:51

DarkCart (41 views)
2014-10-26 19:37:11

Luminem (22 views)
2014-10-26 10:17:50

Luminem (27 views)
2014-10-26 10:14:04

theagentd (33 views)
2014-10-25 15:46:29

Longarmx (61 views)
2014-10-17 03:59:02

Norakomi (59 views)
2014-10-16 15:22:06

Norakomi (47 views)
2014-10-16 15:20:20

lcass (43 views)
2014-10-15 16:18:58
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

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
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!