use the standard hitTest utility method.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1362 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: ObjectTile.java,v 1.7 2002/05/06 18:08:32 mdb Exp $
|
// $Id: ObjectTile.java,v 1.8 2002/05/16 01:49:38 ray Exp $
|
||||||
|
|
||||||
package com.threerings.media.tile;
|
package com.threerings.media.tile;
|
||||||
|
|
||||||
@@ -8,6 +8,7 @@ import java.awt.Rectangle;
|
|||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
|
|
||||||
import com.threerings.media.Log;
|
import com.threerings.media.Log;
|
||||||
|
import com.threerings.media.util.ImageUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object tile extends the base tile to provide support for objects
|
* An object tile extends the base tile to provide support for objects
|
||||||
@@ -108,17 +109,8 @@ public class ObjectTile extends Tile
|
|||||||
*/
|
*/
|
||||||
public boolean hitTest (int x, int y)
|
public boolean hitTest (int x, int y)
|
||||||
{
|
{
|
||||||
if (_image instanceof BufferedImage) {
|
Log.info("hit test " + x + ", " + y + " (" + ImageUtil.hitTest(_image, x, y));
|
||||||
BufferedImage bimage = (BufferedImage)_image;
|
return ImageUtil.hitTest(_image, x, y);
|
||||||
int argb = bimage.getRGB(x, y);
|
|
||||||
// it's only a hit if the pixel is non-transparent
|
|
||||||
return (argb >> 24) != 0;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Log.warning("Can't check for transparent pixel " +
|
|
||||||
"[image=" + _image + "].");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// documentation inherited
|
// documentation inherited
|
||||||
|
|||||||
Reference in New Issue
Block a user