etxztn / pulpcore

Automatically exported from code.google.com/p/pulpcore
0 stars 0 forks source link

Irregular results with pixel-level intersections #10

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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

GoogleCodeExporter commented 8 years ago
Thanks for posting this. This is fixed, in SVN, and will show up in the nightly 
build in a few hours.

Original comment by brack...@gmail.com on 26 May 2008 at 5:10