omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    Scene update()

    Pythonista
    update scene
    1
    2
    993
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • resserone13
      resserone13 last edited by resserone13

      I was trying to have a timer update every time a sprite is tapped 20 times. I would like the code to be executed once every 20 taps. When I put the code in the update() it executes the code more than once more. How do I control this. I would like to have a condition checked all the time but only happen once whenever the condition is true.

      
      		
              Def update(self):
                  if self.tap_count == 20:
      			       self.timer_value += 15
      
      
      1 Reply Last reply Reply Quote 0
      • resserone13
        resserone13 last edited by resserone13

        I put this code under touch_began() and its how I want. Every time the button is clicked the amount of taps is checked and if it meets the condition it adds 15 to the time.

        
        			if self.tap_count % 20 == 0 and self.tap_count != 0:
        				self.timer_value += 15
        
        
        1 Reply Last reply Reply Quote 0
        • First post
          Last post
        Powered by NodeBB Forums | Contributors