Hello,
I'm quite new to SFML and this forum as well, so please excuse me if my conduct is abnormal.
I have a question about the
draw method, the one from the
Drawable base class.
The thing is, I have a class named MapStrip(drawable, transformable), of which several Tilemaps(like the ones on the tutorial) are private members. They represent different layers. I wrote the logic of the draw method as so:
void MapStrip::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
//draw each layer
target.draw(WallStrip, states);
target.draw(FloorStrip, states);
target.draw(ObjectLayer1, states);
target.draw(ObjectLayer2, states);
}
Since they are allways drawn in that order, I find no apparent algorythmic flaw... Unless of course, the
draw method is not what I think it is.
The
problem is: I'm only able to see the last thing I tell it to draw. In this case, the ObjectLayer2. If the line
target.draw(WallStrip, states); came after it, then I would only see the WallStrip being displayed.
Does the draw method literally draw on the go? Or does it simply assing an "object" to the target and it's drawn after that, out of my control? I'm asking because I placed several breakpoints along this method and noticed nothing is drawn until it is exited.
If so, how can something like this be solved?
Thank you very much.
I will include below the code for the draw method on the Tilemap class:
void Tilemap::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
// apply the transform
states.transform *= getTransform();
// apply the tileset texture
states.texture = &Tileset;
// draw the vertex array
target.draw(Vertices, states);
}