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.


    Shake Device

    Pythonista
    2
    3
    2779
    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.
    • NoBetterName
      NoBetterName last edited by

      I'm using the scene module, and I'm in the update function of my scene class. I need to check to see if the user shook the device. Just one quick movement is all I need. It will probably be more like flicking the device. Should I just check for a drastic and quick change in the gravity? Any other suggestions?

      1 Reply Last reply Reply Quote 0
      • NoBetterName
        NoBetterName last edited by

        Hey everybody, solved the problem. I checked for changes in gravity. If the difference in gravity over one frame was above a certain number, then it was flicked. But for anybody else who might want to do this in the future, does anybody have any ideas on shaking the device? How would you check for a big shake? My method wouldn't work. Like the shake for the undo button.

        1 Reply Last reply Reply Quote 0
        • JonB
          JonB last edited by

          You can achieve the shake to undo effect using objc_util, thought that may be overkill
          https://developer.apple.com/library/content/documentation/EventHandling/Conceptual/EventHandlingiPhoneOS/motion_event_basics/motion_event_basics.html#//apple_ref/doc/uid/TP40009541-CH6-SW2
          It would take a little effort to translate this to pythonista, and you would have to be careful about management of the callback/globals, but should be totally doable, and then you don't have a tight loop checking accel data which would waste battery.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors