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


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;

protected void onManagedDraw(GL10 pGL, Camera pCamera)


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

        super.onManagedDraw(pGL, pCamera);





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.


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.

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.