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 - dm

Pages: [1]
1
Graphics / Re: sf::Transformable::getTransform() broken?
« on: November 06, 2014, 09:09:10 pm »
Many thanks, that last post is very helpful.

2
Graphics / Re: sf::Transformable::getTransform() broken?
« on: November 06, 2014, 08:08:26 pm »
Ok. Then why child drawn over parent? parent global top-left is (50, 50), global coords of "parent origin" m_origin = (0, 0).

What i trying to explain is exact behaviour of SpriteKit. I try understood why SFML and SpriteKit behaves so differently.
(btw, cocos2d behaves like SFML)

3
Graphics / Re: sf::Transformable::getTransform() broken?
« on: November 06, 2014, 07:44:43 pm »
What the "parent origin" is?
This is its top-left corner or m_origin?

4
Graphics / Re: sf::Transformable::getTransform() broken?
« on: November 06, 2014, 02:03:27 pm »
But this is incorrect interpretation of parent-child relationship!
As an example, same parent-child in SpriteKit:
SKSpriteNode *parent = [SKSpriteNode spriteNodeWithColor:[SKColor greenColor] size:CGSizeMake(50, 50)];
[parent setAnchorPoint:CGPointMake(-1, -1)]; // same as {-50, -50} in SFML
[self addChild:parent];
   
SKSpriteNode *child = [SKSpriteNode spriteNodeWithColor:[SKColor redColor] size:CGSizeMake(50, 50)];
[child setAnchorPoint:CGPointMake(0, 0)]; // set to {0, 0} because default anchor is {0.5, 0.5}
[parent addChild:child];
 

See attached screenshot: child correctly positioned at parent origin.

5
Graphics / sf::Transformable::getTransform() broken?
« on: November 06, 2014, 12:56:46 pm »
Consider this:
int main(int, char const**)
{
    sf::RenderWindow window(sf::VideoMode(480, 320), "SFML window");
   
    sf::RectangleShape parent;
    parent.setSize({50, 50});
    parent.setFillColor(sf::Color::Green);
    parent.setOrigin({-50, -50});
   
    sf::RectangleShape child;
    child.setSize({50, 50});
    child.setFillColor(sf::Color::Red);
   
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed) {
                window.close();
            }
        }

        window.clear();
        window.draw(parent);
        // child should be drawn at origin, but instead it drawn over parent.
        window.draw(child, parent.getTransform());
        window.display();
    }
    return EXIT_SUCCESS;
}
 

I think, child should be drawn at parent origin but instead it drawn over parent. It is a bug in getTransform() or I misunderstood something?

Pages: [1]