SFML community forums

Bindings - other languages => Python => Topic started by: HuFlungDu on March 05, 2013, 07:14:25 pm

Title: pysfml-cython overriding draw method
Post by: HuFlungDu on March 05, 2013, 07:14:25 pm
Hello everyone. After some time I am returning to sfml using pysfml-cython and am trying to get my bearings, not doing anything special. I'm trying to write a simple class that extends RectangleShape to draw another object inside of it. Judging from the documentation (http://pysfml2-cython.readthedocs.org/en/latest/reference/graphics/drawing.html#graphicsref-custom-drawables) I should be able to write a class the extends Transformable (RectangleShape eventually does) and just override the draw function like normal, but making a class like this:
Code: [Select]
class DrawingRect(sfml.RectangleShape):
    def __init__(self):
        sfml.RectangleShape.__init__(self,(100,100))

    def draw(self, target, states):
        print "here"
Instead of drawing nothing when I call window.draw(myrect) and printing "here", it just draws the rectangle like normal and prints nothing, meaning it's not calling my new draw function. Am I missing something? Is there another class I need to inherit? Thanks.