Slick Forums

Discuss the Slick 2D Library
It is currently Tue May 21, 2013 11:32 pm

All times are UTC




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Wed Jul 04, 2012 9:10 pm 
Offline

Joined: Sun Jul 01, 2012 5:02 am
Posts: 3
Hello, I'm currently working on a Slick2D game and I'm wondering about how mouseclicks work.

Here's the code in question:

https://github.com/argoneuscze/Seafloor ... utton.java
(please let me know if there are any major flaws :3)

Thing is, if I press and hold the mouse outside the button rectangle and then move the mouse inside the button, it returns true. How can I do it so you need to press and unpress the button inside the box for it to work?


Top
 Profile  
 
PostPosted: Wed Jul 04, 2012 9:22 pm 
Offline

Joined: Sat Jun 02, 2012 7:41 am
Posts: 67
Maybe using isMousePressed(..)? I never tried to handle the mouse input so I'm not sure.

In case the method above doesn't work, you could try to add a "pressed" boolean variable and modify your code like this:
Code:
if (input.isMouseButtonDown(..) && this.pressed == false) {
// ... all you have to do...
this.pressed = true;
}

and then change the value of the variable pressed to false if the mouse button is not pressed. Something like this :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group