C API sprite->setClipRect problem

Hello everyone,

I'm having some trouble getting pd->sprite->setClipRect to work. Basically, no matter what I set the values to in the LCDRect, the entirety of the sprite is removed (you can see in my commented line I tried setting it to the full screen, still hides the entire sprite). Any ideas what I might be overlooking?

Thanks in advance,

static void updateCigMeter(LCDSprite* cigMeter)
float x, y;
pd->sprite->getPosition(cigMeter, &x, &y);

int newY = y;
int newX = x;
LCDRect cigMeterClipRect = {newX - 39, newY - 6, 39, 11};
//LCDRect cigMeterClipRect = {0, 0, 400, 240};
pd->sprite->setClipRect(cigMeter, cigMeterClipRect);


static LCDSprite* createCigMeter(int xPos, int yPos)
LCDSprite *cigMeter = pd->sprite->newSprite();
pd->sprite->setUpdateFunction(cigMeter, updateCigMeter);
int w;
pd->graphics->getBitmapData(cigMeterImage, &w, &cigMeterImageHeight, NULL, NULL, NULL);
pd->sprite->setImage(cigMeter, cigMeterImage, kBitmapUnflipped);
pd->sprite->moveTo(cigMeter, xPos, yPos);

pd->sprite->setZIndex(cigMeter, 500);

return cigMeter;


Correct me if I'm wrong, but I believe the clipping rectangle for a sprite is relative to the sprite coordinate system, not that of the screen. For a clip on the entire screen, you'd want to use

thanks scratchminer, I am trying to just clip the sprite. I did the {0,0,400,240} as a catch all figuring it should show 100% of the sprite regardless given those coordinates

I did notice in the documentation, the parameters for LCDRect and PDRect are different, not sure what to make of that

typedef struct
int left;
int right;
int top;
int bottom;
} LCDRect;

typedef struct
float x;
float y;
float width;
float height;
} PDRect;

I gave up on clipping the sprite and just drew a white box over where it needed to be "clipped"