drawing Decal on Decal --> no transparency possible?
TuxxuT opened this issue · comments
For my game board I use some PNGs with a transparent background.
bool OnUserCreate() override
{
prisonSprite = std::make_unique<olc::Sprite>("assets/prison.png");
decalPrisonSprite = std::make_unique<olc::Decal>(prisonSprite.get());
playerSprite = std::make_unique<olc::Sprite>(PLAYER_SIZE_RADIUS*2+1, PLAYER_SIZE_RADIUS*2+1);
SetDrawTarget(playerSprite.get());
DrawLine(0, 0, playerSprite.get()->width, playerSprite.get()->height);
SetDrawTarget(nullptr);
decalForPlayerSprite = std::make_unique<olc::Decal>(playerSprite.get());
}
}
bool OnUserUpdate(float fElapsedTime) override
{
SetPixelMode(olc::Pixel::MASK);
// Erase previous frame
Clear(olc::BLACK);
DrawRotatedDecal(olc::vi2d(75, 375), decalPrisonSprite.get(), (45 * M_PI / 180), { 16,16 }, { 0.60,0.60 }, olc::WHITE);
}
During the game it naturally happens that a player (sprite) moves across a field with PNG (here with the decalPrisonSprite)...
As you can see from the screenshot, in this case the background of the player sprite is not displayed transparently...
I'm currently not sure what I'm doing wrong?
The values of the black pixels (the background) of the player sprite are (R=0, G=0, B=0, A=255).
Maybe that's the mistake?
Thank you!!
Indeed. After setting the draw target I typically will do Clear(olc::BLANK)
for transparent pixels across the entire image. Default is all black.
This leads to success!