The Sprite.intersects(Sprite) method doesn't seem to be working properly on
ImageSprites with custom aspect ratios and pixel-level intersections.
Simple test scene (Use the background image from the Hello World example):
public class TestScene extends Scene2D {
private FilledSprite sprite;
private ImageSprite sprite2;
public void load() {
Sprite background = new
FilledSprite(0,0,Stage.getWidth(),Stage.getHeight(), Colors.BLUE);
add(background);
sprite = new FilledSprite(200,200,100,100, Colors.WHITE);
sprite2 = new ImageSprite("background.png",200,200,50,100);
add(sprite);
add(sprite2);
// sprite2.setPixelLevelChecks(false);
}
public void update(int elapsedTime) {
super.update(elapsedTime);
sprite.setLocation(Input.getMouseX(),Input.getMouseY());
if(sprite.intersects(sprite2)) {
sprite.alpha.set(50);
} else {
sprite.alpha.set(255);
}
}
}
Uncommenting the "sprite2.setPixelLevelChecks(false)" line produces the
expected results.
Original issue reported on code.google.com by will.jor...@gmail.com on 26 May 2008 at 4:25
Original issue reported on code.google.com by
will.jor...@gmail.com
on 26 May 2008 at 4:25