Luk,
That sounds super cool. Checking out your script as soon as I can!
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.
Luk,
That sounds super cool. Checking out your script as soon as I can!
I've been using gravity() during a scene's setup to establish the starting position of the device. It works great on my iPad Air. My iPhone 5, however, doesn't seem to get any values from gravity() when run during setup.
To test this, check out the following code: https://gist.github.com/andrewschmidt/8293953
Run on my iPad Air, tilted mostly vertical, this outputs:
(0.01366471778601408, -0.8423394560813904)
Run on my iPhone 5, in any position:
(0.0, 0.0)
It's worth noting that in my actual script, the gravity() call made after the scene has begun looping works fine on the iPhone. It's only in setup that it doesn't return anything.
I don't know which is the intended behavior, but it can't be both!
And I'm back a couple minutes later with a discovery.
I added a hack-y bit of code—I stuck the gravity() call in a WHILE loop that doesn't end until it gets values different than zero.
This mostly solved the problem on my iPhone. Based on just how it feels to use gravity() to move a rect around, it seems like the accelerometer takes a second or two after it begins returning values to return correct values. I wouldn't expect Pythonista to do anything about that—it's just something devs will have to be aware of.
In summary: Looks like the iPhone 5 is a bit slower about either getting gravity() up and running, or getting values from the system's accelerometer. A little too slow to get any information before a scene has finished with setup.
Curiously I was working on a program that required this very thing—keyboard during scene (it's a typing game).
I don't think I'm likely to finish it (in Pythonista, that is), but it'd be a neat feature. Screenshotting the keyboard isn't so bad, though.
It's almost unreal you made a game this great within Pythonista. I've no idea what game this is based on or how similar it is, but apart from the copyright issues this would be a cool thing to try to package and release as a standalone app!
I know it's been forever since you posted this, but I hope you're still working on it! It's a super cool engine, at least, and I'm impressed at how fast it runs!