• Elden12360

    I am a VERY new person to python and pythonista(not ot coding though, for I have been programming in Lua and C++ and Java for the last 8 months). So this error that i am getting is really bothering me here is the code and error. Please Help.

    from scene import *
    
    class MyScene (Scene):
        def setup(self):
            # This will be called before the first frame is drawn.
            show = 0
            pass
            
        def draw(self):
            # This will be called for every frame (typically 60 times per second).
            background(0, 0, 0)
            # Draw a red circle for every finger that touches the screen:
            fill(0.50, 1.00, 0.00)
            rect(100, 100, 150, 50)
            fill(1, 0, 0)
            
            if show == 1:                                                #HERE IS WHERE MY ERROR IS TAKING PLACE
                ellipse(500, 400, 100, 100)                                            
    
            for touch in self.touches.values():
                #ellipse(touch.location.x - 50, touch.location.y - 50, 100, 100)
                if touch.location.x > 99:
                    if touch.location.x < 251:
                        if touch.location.y > 99:
                            if touch.location.y < 151:
                                show = 1
        
        def touch_began(self, touch):
            pass
    
        def touch_moved(self, touch):
            pass
    
        def touch_ended(self, touch):
            pass
    
    run(MyScene())
    

    The error says UnboundLocalError: local variable 'show' referenced before assignment

    posted in Pythonista read more
  • Elden12360

    So when ever I want to use a variable all throughout my code I should make it self.

    posted in Pythonista read more
  • Elden12360

    Thank you so much!!! That really helped!

    posted in Pythonista read more

Internal error.

Oops! Looks like something went wrong!