5
\$\begingroup\$

I want to implement masking with sprite in Andengine. I want same functionality as in ios class called

SKCropNode

which works like an masking node! Is there any workaround like this in andengine/opengl ? Thanks.

Edit: This is something I was trying to mask an entity, got no effect, any suggestion?

public class ClippingEntity extends Entity//BaseSprite
{

protected int mWidth;
protected int mHeight;

public ClippingEntity(float pX, float pY, int pWidth, int pHeight, TextureRegion t)
{
    super(pX, pY);//, pWidth, pHeight, t);
    mWidth = pWidth;
    mHeight = pHeight;
}

@Override
protected void onManagedDraw(GL10 pGL, Camera pCamera)
{

    pGL.glPushMatrix();
    {

        pGL.glEnable(GL10.GL_SCISSOR_TEST);
        pGL.glScissor(0 + (int) mX, 800 - mHeight + (int) mY, mWidth, mHeight);

        super.onManagedDraw(pGL, pCamera);

        pGL.glDisable(GL10.GL_SCISSOR_TEST);

    }
    pGL.glPopMatrix();

}

}

I have also tried Stencil Test but it just clears the color of rectangle. ref: opengl mask tests

Ultimate goal is to disable drawing changes in specific entity where it may aslo have transparent background.

\$\endgroup\$

1 Answer 1

0
\$\begingroup\$

You miss some important things. You have to transform the clip-coordinates to camera coordinates and do the clipping with those. But you dont have to reinvent the wheel. Go to github - andengine - there is already a class called ClipEntity that does exactly what you want to achieve.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .