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
-
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?
-
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.
-
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.