Gyroscope access on mobile

Something you want to see in a LiveCode product? Want a new forum set up for a specific topic? Talk about it here.

Moderator: Klaus

Post Reply
splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Gyroscope access on mobile

Post by splash21 » Sun May 26, 2013 11:56 pm

Coding tilt control into apps requires access to the gyroscope, but - as far as I'm aware - we don't have this yet :(
LiveCode Development & Training : http://splash21.com

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Gyroscope access on mobile

Post by sturgis » Mon May 27, 2013 12:00 am

using the accelerometer works fine. I have a simple stack that runs on my kindle that rolls a ball around the screen using tilt. Works pretty well.

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: Gyroscope access on mobile

Post by splash21 » Mon May 27, 2013 9:44 am

Thanks, Sturgis. The last time I tried using the accelerometer (some time ago!) I was sure that the accelerometer only gave you rate of change and reset to 0 when the device stopped moving, but after reading your reply, I gave it a quick test and it looks good! :D
LiveCode Development & Training : http://splash21.com

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Gyroscope access on mobile

Post by sturgis » Mon May 27, 2013 12:44 pm

Works pretty darn well actually, and has some interesting affects too. (like an inertial affect.. if I push it straight sideways hard, the ball moves opposite (in relation to the kindle surface) as if it actually has some real mass and wishes to stay at rest. Hmm. wishes? Well you know what I mean. And yeah, no return to zero because (to steal a line from fraggle rock) "gravity works!"

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: Gyroscope access on mobile

Post by splash21 » Tue May 28, 2013 1:12 pm

I'm liking tilt controls! :D

http://youtu.be/NOnWNr-EVUQ
LiveCode Development & Training : http://splash21.com

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Gyroscope access on mobile

Post by sturgis » Tue May 28, 2013 1:28 pm

That is working SO nice.

So, the background. Is it 1 big graphic? Set the angle, calc the scroll values to keep the right spot under the flyer? Or individual blocks stitched together, all with angle set and position calced? Or a combination maybe? Either way, its nice and smooth!

Also like that your intersect/clipping stuff works so well.

splash21
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 369
Joined: Sun Dec 19, 2010 1:10 am
Contact:

Re: Gyroscope access on mobile

Post by splash21 » Tue May 28, 2013 2:47 pm

The map is a 1000x1000 grid - each grid square is 64x64 pixels. There are 100 image objects - every time a new frame is to be drawn, the objects from the map (a 1000x1000 array) that will be on screen are calculated and then the image objects are used 1 by 1 to create the scene - unused images are hidden. All objects are redrawn with angle and position recalculated relative to the ships position and heading. Using this approach, a much bigger map can be loaded and run at the same speed with no additional overhead.

B)
LiveCode Development & Training : http://splash21.com

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: Gyroscope access on mobile

Post by sturgis » Tue May 28, 2013 4:07 pm

That is snazzy. Kinda like the datagrid, only render the onscreen stuff.

Don't suppose you're going to create a library/3rd party addon out of your project? It works really well!

Post Reply