In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "how to develop the Shake Mini Program system". In the daily operation, I believe many people have doubts about how to develop the Mini Program system. The editor consulted all kinds of materials and sorted out simple and easy-to-use methods of operation. I hope it will be helpful to answer the doubts about how to develop the Mini Program system. Next, please follow the editor to study!
/ / first define the global variable
Var lastTime = 0 position / this variable is used to record the time of the last shake.
Var Xero0
Y = 0
Zhen0
LastX = 0
LastY = 0
LastZ = 0 position / this group of variables records the values of the corresponding x, y, z axes and the last values, respectively.
Var shakeSpeed = 110ram / set threshold
/ / write a shake method
Function shake (acceleration) {
Var nowTime = new Date () .getTime (); / / record the current time
/ / if there is a certain interval between the time of this shake and the last one, it will be carried out.
If (nowTime-lastTime > 100) {
Var diffTime = nowTime-lastTime;// recording time period
LastTime = nowTime;// record the shaking time to prepare for the next calculation of the shaking time
X = acceleration.x;// gets the value of the x axis, which is perpendicular to the north axis and positive to the east
Y = acceleration.y;// gets the y-axis value, and the y-axis is positive to the north
Z = acceleration.z;// gets the value of the z axis, which is perpendicular to the ground and positive upward
/ / the calculation formula means the distance of movement per unit time, that is, the speed we want.
Var speed = Math.abs (x + y + z-lastX-lastY-lastZ) / diffTime * 10000
/ / console.log (speed)
If (speed > shakeSpeed) {/ / if the calculated speed exceeds the threshold, then the user shakes successfully
Wx.stopAccelerometer ()
Self.setData ({
HasInit: false
Canvas: {}
})
AudioCtx.setSrc ('http://123.207.0.183/application/images/s.mp3')
AudioCtx.play ()
Wx.showLoading ({
Title: 'search for the Great Gods.'
})
Config.request ({
/ / the address to be requested
Url: config.service.taRan
Success (e) {
SetTimeout (function () {
/ / console.log (e.data)
AudioCtx.setSrc ('http://123.207.0.183/application/images/r.mp3')
AudioCtx.play ()
Self.uid = e.data
Self.con =''
Self.onInitShow ()
}, 2000)
}
})
}
LastX = x _ position / assignment to prepare for the next calculation
LastY = y _ position / assignment to prepare for the next calculation
LastZ = z _ position / assignment to prepare for the next calculation
}
}
Wx.onAccelerometerChange (shake)
/ / wx.startAccelerometer ()
Var audioCtx = wx.createAudioContext ('myAudio')
Reminder: the src of audio API cannot use a local address.
At this point, the study of "Shake Mini Program system how to develop" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.