Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By Fubarable

Thread: Mouse over check

  1. #1
    TideS is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Question Mouse over check

    Hi guys. My game have isometric map. And i need check - @is mouse over object?@ for tile highlighting and other important things. Please, I need your help!

    I can give you any source if you need.

    Best regards,

    TideS

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Mouse over check

    I would use a MouseAdapter which can function as both a MouseListener and a MouseMotionListener. For an example of this, please see: java-mouseclicked-problem

  3. #3
    TideS is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: Mouse over check

    Fudarable, Thx, it works. But i use images, like
    g2.drawImage();
    no rectangles. And the tiles are not rectangular:

    http://s1.ipicture.ru/uploads/20111029/wPQNRWaR.png
    Attached Thumbnails Attached Thumbnails Mouse over check-wpqnrwar.png  

  4. #4
    TideS is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: Mouse over check

    Okay i have a array of rects. How do i check?

    Java Code:
    for (int i = 0; i < map.length; i++) {
    
    				for (int j = 0; j < map[0].length; j++) {
    
    					if (map[i][j].rectangle.contains(e.getPoint())) {
    
    						System.exit(0);
    
    					}
    
    				}
    
    			}
    It's not work...

  5. #5
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,233
    Rep Power
    7

    Default Re: Mouse over check

    Why do you have a 2D array or rectangles?

    For more help, post your Short, Self Contained, Correct Example that demonstrates the problem.
    Last edited by camickr; 10-30-2011 at 04:02 PM.

  6. #6
    TideS is offline Member
    Join Date
    Oct 2011
    Posts
    4
    Rep Power
    0

    Default Re: Mouse over check

    https://github.com/TideSofDarK/Life-on-an-Island

    It's source code, problem in Island.java
    (https://github.com/TideSofDarK/Life-...nd/Island.java)

    I have an array of Sprites, and each sprite has a rect. I must check - "is mouse over rect".

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default Re: Mouse over check

    Quote Originally Posted by TideS View Post
    https://github.com/TideSofDarK/Life-on-an-Island

    It's source code, problem in Island.java
    (https://github.com/TideSofDarK/Life-...nd/Island.java)

    I have an array of Sprites, and each sprite has a rect. I must check - "is mouse over rect".
    I can't believe that you have read camickr's post, since these links are to pages and pages of code. If you want to pay one of us to review all this code for you, that would be one thing, but if you're asking volunteers to go through all of this in their free time, I think you have unrealistic expectations. Please read through camickr's link again, and then if you're still having problems, and still need our help, you may wish to put in the effort to create and post a workable SSCCE of reasonable size.

    Luck.
    camickr likes this.

Similar Threads

  1. Mouse Dragged
    By chetoos in forum Advanced Java
    Replies: 11
    Last Post: 06-24-2011, 03:18 AM
  2. Check if image contains mouse
    By trishtren in forum Java 2D
    Replies: 2
    Last Post: 05-15-2011, 10:49 PM
  3. Mouse Buttons
    By xael in forum New To Java
    Replies: 1
    Last Post: 09-07-2010, 11:39 PM
  4. Mouse
    By PhQ in forum AWT / Swing
    Replies: 18
    Last Post: 08-18-2010, 04:05 PM
  5. Mouse Listener for mouse floating over object?
    By Krooger in forum AWT / Swing
    Replies: 1
    Last Post: 11-18-2009, 04:34 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •