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

cordova-plugin-shake

by falsam Wed Mar 21, 2018 3:29 pm

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 10 - JDK 1.8 - SB 2.20 - Android 5.5
http://falsam.com

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

Re: cordova-plugin-shake

by Dirk Geppert Fri Mar 23, 2018 8:01 am

Good to know. I could use that soon. Thank you, Falsam.
Return to Tricks 'n' Tips

Who is online

Users browsing this forum: No registered users and 2 guests