cordova-plugin-shake

Share your advanced knowledge/code with the community.
falsam
Posts: 280
Joined: Mon May 05, 2014 9:49 pm
Location: France
Contact:

cordova-plugin-shake

Post by falsam »

Practice with Cordova : Shake gesture detection.

■ Platform
Android
iOS ?

■ Documentation https://www.npmjs.com/package/cordova-plugin-shake

Code: Select all

EnableExplicit

Enumeration
  #mf
EndEnumeration

Declare Start()
Declare InitShake(SuccessCallback, Sensitivity = 30)
Declare onSuccess()

;Import Cordova Plugin
Import "cordova plugin add cordova-plugin-shake"
EndImport

Start()

Procedure Start()  
  OpenWindow(#mf, 0, 0, 0, 0, "Shake your phone", #PB_Window_Background)
  InitShake(@onSuccess(), 8)  
EndProcedure

Procedure InitShake(SuccessCallback, Sensitivity = 30)
  !shake.startWatch(v_successcallback, v_sensitivity)    
EndProcedure

Procedure onSuccess() 
  Debug "Shake : New dice " + Random(6,1)
EndProcedure

If you need to stop detection, use this procedure

Code: Select all

Procedure StopShake()
  !shake.stopWatch()
EndProcedure
I don't know if it works for iOS

➽ Windows 11 - JDK 1.8 - SB 2.40 - Android 13
http://falsam.com

Sorry for my poor english
Dirk Geppert
Posts: 282
Joined: Fri Sep 22, 2017 7:02 am

Re: cordova-plugin-shake

Post by Dirk Geppert »

Good to know. I could use that soon. Thank you, Falsam.
Post Reply