Navigation

    Fuze Arena Logo
    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Help
    • Discord

    Touch state

    Beginners
    2
    3
    217
    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.
    • D
      Devoid21 last edited by

      How can I make a button press register after touch has ended? Want to make it register once you lift the finger from the screen.

      1 Reply Last reply Reply Quote 1
      • pianofire
        pianofire Fuze Team last edited by pianofire

        Something like this:

        pressed = false
        state = false
        buttonPos = { gwidth() / 2, gheight() / 2 }
        radius = 50
        loop
          clear()
          printat( 0, 0, pressed )
          pressed = buttonPressed()
          if state and !pressed then
            playNote( 0, 3, 800, 0.5, 10, 0.5 )
          endif
          circle( buttonPos.x, buttonPos.y , radius, 100, red, false)
          update()
          state = pressed
        repeat
        
        function buttonPressed()
          var result = false
          var list = touch()
          for i = 0 to len (list) loop
            pos = list[i]
            if distance( pos, buttonPos ) < radius then
              result = true
            endif
          repeat
        return result
        
        1 Reply Last reply Reply Quote 2
        • D
          Devoid21 last edited by

          Thanks pianofire, your a sanity saver 😂

          1 Reply Last reply Reply Quote 1
          • First post
            Last post