AndEngine : Collision does not make line disappear

| | August 4, 2015

I have drawn the line between two sprites and there is a rectangle.
When the line collides with rectangle the line should be invisible else the line should be visible.
But i am having problem with line visibility. the line is invisible in some places but visible during rectangle collision.
Needed help.
My update code is as follows:

final Line e1line = new Line(sprite1.getX(), sprite1.getY(), sprite2.getX(), sprite2.getY(),getVertexBufferObjectManager());
e1line.setColor(1, 1, 0);
myscene.attachChild(e1line)
IUpdateHandler updatehand = new IUpdateHandler() {
@Override
public void onUpdate(float pSecondsElapsed) {
e1line.setPosition(sprite1.getX(), sprite1.getY(), sprite2.getX(), sprite2.getY());
if( e1line.collidesWith(rectborder.get(0)) ){
e1line.setVisible(false);
}else{
e1line.setVisible(true);
}
}

@Override
public void reset() {

}
};

Samples

Leave a Reply