SFML community forums

Help => Graphics => Topic started by: fatih on December 28, 2012, 07:41:47 pm

Title: My character has box around it
Post by: fatih on December 28, 2012, 07:41:47 pm
I am trying to make some basic exercise of one simly game. Character  is loaded from file, but it have box around it. With aseprite i put transparent background of character, but it still have box. Dimensions of character is 30x30.

[attachment deleted by admin]
Title: Re: My character has box around it
Post by: Nexus on December 28, 2012, 07:45:31 pm
Use PNG instead of Bitmaps, and make the parts outside the character transparent (alpha value 0).

If you can say that all pixels with a certain color should be transparent, you can use color masks with sf::Image::createMaskFromColor().
Title: Re: My character has box around it
Post by: timo777 on December 28, 2012, 08:24:25 pm
Sidenote: Try to hold your width and height equal to powers of 2. So that your sprite is 32x32. Because usually screen dimensions are in powers of 2.
Title: Re: My character has box around it
Post by: eXpl0it3r on December 28, 2012, 08:54:40 pm
Because usually screen dimensions are in powers of 2.
So? ;D

It really is not important what width and height is used, as long as it fits the needs.
Many people use numbers with power of 2, but mostly because of either old times where for instance graphic cards only supported textures with sides of power by two or because it's a bit geeky and sometimes makes things fit a bit nicer, but if there's no need, then it's rather bad to do stuff just because. ;)
Title: Re: My character has box around it
Post by: masskiller on December 28, 2012, 09:30:42 pm
Sidenote: Try to hold your width and height equal to powers of 2. So that your sprite is 32x32. Because usually screen dimensions are in powers of 2.

This is useful for repeated textures, but outside of it, it doesn't really matter or even is worth it since it limits you and may make you have a texture size filled with extra alpha just for the sake of it.
Title: Re: My character has box around it
Post by: FRex on December 28, 2012, 09:36:38 pm
I think SFML will make textures go up to closest bigger power of 2 if gpu needs that. So don't do that yourself.
Title: Re: My character has box around it
Post by: fatih on December 29, 2012, 06:52:28 pm
Thanks, you are all right, but i found best solution: go to aseprite pick transparent color and draw mask. Sorry for my Englich.