Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - inf4ax

Pages: [1]
1
Graphics / Re: Problem with layers in tilemap system.
« on: February 09, 2015, 10:36:43 pm »
Thank for reply, but i have a file with true alpha channel ( http://postimg.org/image/w86zjzpe7/ )
I tried the function getColorMaskFrom and did not work
void TileMap::convertColorMask(std::string path)
{
        sf::Image buffer;
        buffer.loadFromFile(path);
        buffer.createMaskFromColor(sf::Color::Transparent,0);
        m_tileset.loadFromImage(buffer);
}
// m_tileset is private member sf::Texture
 

2
Graphics / Problem with layers in tilemap system.
« on: February 09, 2015, 10:15:11 pm »
Hello.
I apologize in advance for my weak English
I wrote a class that draws tilemap several layers , but I have a problem because the tile layer "solid " or " object" draw  with a black border ( alpha channel is black )
Shows how it looks more or less
I read data from XML.

Problem exist in layer other than bg, while dot is "player"
"bg" tiles is always appended to vertex array first than "solid" or "objects"
// class declaration TileMap : public sf::Drawable, public sf::Transformable
// i try set sf::BlendAlpha, no effect
while(tile)
                {

                        if(lName == "bg")                                                      
                        {
                                appendTile(x,y,tileNumber);
                        }
                        if(lName == "solid" && tileNumber != -1)       
                        {                                                                                      
                                appendTile(x,y,tileNumber);
                                solidTiles.push_back(SolidTile(x,y));
                        }


                }
 
and append tile function.
void TileMap::appendTile(const sf::Int32 x,const sf::Int32 y, const sf::Int32 GID)
{
        sf::Int32 tu = GID % (m_tileset.getSize().x / tile_width);
        sf::Int32 tv = GID / (m_tileset.getSize().x / tile_height);
        sf::Vertex* quad = &m_vertices[(x + y * width_in_tiles) * 4];
             
        quad[0].position = sf::Vector2f(x * tile_width, y * tile_height);
        quad[1].position = sf::Vector2f((x + 1) * tile_width, y * tile_height);
        quad[2].position = sf::Vector2f((x + 1) * tile_width, (y + 1) * tile_height);
        quad[3].position = sf::Vector2f(x * tile_width, (y + 1) * tile_height);
                       
        quad[0].texCoords = sf::Vector2f(tu * tile_width, tv * tile_height);
        quad[1].texCoords = sf::Vector2f((tu + 1) * tile_width, tv * tile_height);
        quad[2].texCoords = sf::Vector2f((tu + 1) * tile_width, (tv + 1) * tile_height);
        quad[3].texCoords = sf::Vector2f(tu * tile_width, (tv + 1) * tile_height);
}
 
problem looks like that

Thanks in advance.



Pages: [1]