[Java]Basic Isometric Issue
Hello,
This is my first post on this forum, although i have visted this site on and off for a couple of years.
I am an amateur programmer currently trying to create an isometric tile editor.
I have been using this article for techniques - http://www.gamedev.net/reference/articles/article747.asp
I am having trouble with the section "mouse matters", when the tile image is colored at corners, in order to + or - the selected row/col. I understand how this works.
Currently my program creates the colored diamonds at the click of a button. The tile size is 198*100. Clicking on the tile then displays the row/col, as well as the internal coordinates of that tile (mouseX,mouseY).
I have been stuck for a week on how to get the RGB color of the pixel on the tile. I am using JLabels instead of bufferedimages. PixelGrabber does not work, and after extensive googling, i read it is apparently very bad to use it anyway since java 1.1.
As i am incapable of getting it to work, is anyone aware of another method to use, explained simply?
I do not know what code i need to post. i assume any code has to go into the area where the ActionEvent (mouseclick) occurs.
regards
A.A.
Use buffered image instead of JLabel and use the getRGB method. JLabel is probably a poor choice for storing a mousemap. Even if you need to display the mousemap to the user, you don't need a JLabel.
You'll get an integer representing a pixel in the TYPE_INT_ARGB color model (see docs linked below).
So if you need to get the RGB out... can do something along the lines..
int red = 0xffff0000; //(the format is AARRGGBB)
int blue = 0xff0000ff;
int green = 0xff00ff00;
int white = 0xffffffff;
int pixel = mouseMap.getRGB(mouseX, mouseY);
if(pixel == red) ; //etc...
Docs:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/BufferedImage.html#getRGB(int,%20int)
You'll get an integer representing a pixel in the TYPE_INT_ARGB color model (see docs linked below).
So if you need to get the RGB out... can do something along the lines..
int red = 0xffff0000; //(the format is AARRGGBB)
int blue = 0xff0000ff;
int green = 0xff00ff00;
int white = 0xffffffff;
int pixel = mouseMap.getRGB(mouseX, mouseY);
if(pixel == red) ; //etc...
Docs:
http://java.sun.com/j2se/1.5.0/docs/api/java/awt/image/BufferedImage.html#getRGB(int,%20int)
Hi, and thanks for reply.
I got the method to work, to an extent.
My program can create a "templateMap" consisting of the colored diamonds and using RGB to get row/col offsets.. My program can also create a "normalMap" consisting of normal diamond tiles.
Alone, they both work, but not together (when they form 2 seperate layers).
I intend to have the "templateMap" at the bottom, with a mouseListener picking up RGB values. On top of that will be the "normalMap" which the user clicks and the row/col will be displayed, depending on the RGB values from "templateMap".
I just need to link htese 2 together and hope it works.
thankyou for help,
A.A.
I got the method to work, to an extent.
My program can create a "templateMap" consisting of the colored diamonds and using RGB to get row/col offsets.. My program can also create a "normalMap" consisting of normal diamond tiles.
Alone, they both work, but not together (when they form 2 seperate layers).
I intend to have the "templateMap" at the bottom, with a mouseListener picking up RGB values. On top of that will be the "normalMap" which the user clicks and the row/col will be displayed, depending on the RGB values from "templateMap".
I just need to link htese 2 together and hope it works.
thankyou for help,
A.A.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement