How to blend the sprite into background?
Posted
by
optimisez
on Game Development
See other posts from Game Development
or by optimisez
Published on 2013-06-29T12:59:35Z
Indexed on
2013/06/29
16:30 UTC
Read the original article
Hit count: 264
I try to blend the character into game but I still cannot remove the blue color in the sprite sheet and discover that the white area of sprite is semi-transparent.
Before that, the color D3DCOLOR_XRGB(255, 255, 255)
is set in D3DXCreateTextureFromFileEx
. You will see the fireball through the sprite.
After I change the color to D3DCOLOR_XRGB(0, 255, 255)
, the result will be
Now, I am trying to remove the blue color of the sprite sheet and my expected result is something like that
Until now, I still cannot figure out how to do that. Any ideas?
void initPlayer()
{
// Create texture.
hr = D3DXCreateTextureFromFileEx(d3dDevice, "player.png", 169, 44,
D3DX_DEFAULT, NULL, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(0, 255, 255),
NULL, NULL, &player);
}
void renderPlayer()
{
sprite->Draw(player, &playerRect, NULL, &D3DXVECTOR3(playerDest.X, playerDest.Y, 0),D3DCOLOR_XRGB(255, 255, 255));
}
void initFireball()
{
hr = D3DXCreateTextureFromFileEx(d3dDevice, "fireball.png", 512, 512,
D3DX_DEFAULT, NULL, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED,
D3DX_DEFAULT, D3DX_DEFAULT, D3DCOLOR_XRGB(255, 255, 255),
NULL, NULL, &fireball);
}
void renderFireball()
{
sprite->Draw(fireball, &fireballRect, NULL, &D3DXVECTOR3(fireballDest.X, fireballDest.Y, 0), D3DCOLOR_XRGB(255,255, 255));
}
© Game Development or respective owner