Forum Archive

[Bug] Node.frame and Node.bbox are 1 pixel too wide and too high

__mw__6m

Hi everybody !

I noticed that when you take the width and height of a node, they are 1 pixel too wide and 1 pixel too high :

class MyScene (Scene):
    def setup(self):
        s=SpriteNode('pzl:BallBlue')
        self.add_child(s)
        s.position = 200,345

        s.size = 15,15

        print s.bbox
        print s.frame

It gives :

(192.50, 337.50, 16.00, 16.00)
(192.50, 337.50, 16.00, 16.00)

It does really matter when you deal with this situation like I did :
You have a parent Node that has a .scale over 100.
You have a child SpriteNode with a size=(1.0,1.0).

You try to know if a ouch happened in the child's frame/bbox :
The given bbox is (x,y,2.0,2.0) instead of (x,y,1.0,1.0).
That means your touch area is 4 time larger that it should be !

class MyScene (Scene):
    def setup(self):
        self.scale = 100

        s=SpriteNode('pzl:BallBlue')
        self.add_child(s)
        s.position = 2,2

        s.size = 1,1

        print s.bbox
        print s.frame

It gives :

(1.50, 1.50, 2.0, 2.0)
(1.50, 1.50, 2.0, 2.0)

I bypassed the bug by storing the bbox and fixing it's height and width with my SpriteNode.size ones. But it would be nice to fix it in the next release :-)

__mw__6m

Up ;)
Does it seem normal to you ?