Shake my iphone?

Previous topic - Next topic

ampos

Does someone has a function to detect if the iPhone has been shaked?

Thank you.
check my web and/or my blog :D
http://diniplay.blogspot.com (devblog)
http://www.ampostata.org
http://ampostata.blogspot.com
I own PC-Win, MacBook 13", iPhone 3G/3GS/4G and iPAC-WinCE

matchy

That's something I have wondered about lately also (for a magic eight ball style app).

When shaken (not "shaked" or stirred) I'd imagine just toggling the extremes although haven't tried any yet. Wouldn't it be just a case of measuring the sensor change amounts? What a x,y,z graph look like?

Kitty Hello

I'd test for X > 1.5


matchy

Something like this works for me:
Code (glbasic) Select

// shakey shakey
FUNCTION shake_input:
IF oMouse[0].xjoy<-0.25 AND shake_toggle<>-1
shake_toggle=-1
ENDIF
IF oMouse[0].xjoy>0.25 AND shake_toggle<>1 OR KEY(KEY_SPACE)
shake_toggle=1
INC shake_count,2
IF shake_count>10
shake_count=0
// shaken
ENDIF
ENDIF
IF shake_count>0
LOCAL temp_sin=SIN(GETTIMERALL())
IF temp_sin>0.99
DEC shake_count
ENDIF
ENDIF
ENDFUNCTION


Also:
ALPHAMODE shake_count/10.0 /// in loop for fade-out