Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dap-hu
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Vũ Gia Vương
dap-hu
Commits
82bcc33b
Commit
82bcc33b
authored
May 11, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix deviceMotionPermission when reload scene
parent
4f8ba74d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
2 deletions
+5
-2
DevicemotionController.ts
assets/scripts/GamePlay/DevicemotionController.ts
+3
-1
Global.ts
assets/scripts/Global.ts
+2
-1
No files found.
assets/scripts/GamePlay/DevicemotionController.ts
View file @
82bcc33b
import
{
eventTarget
,
PLAY_ROLLING_SOUND
}
from
"../Events"
;
import
{
Global
}
from
"../Global"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -14,7 +15,7 @@ export default class DevicemotionController extends cc.Component {
private
_isShake
=
false
;
protected
onLoad
():
void
{
if
(
cc
.
sys
.
os
===
cc
.
sys
.
OS_IOS
)
{
if
(
cc
.
sys
.
os
===
cc
.
sys
.
OS_IOS
&&
!
Global
.
deviceMotionPermission
)
{
this
.
node
.
on
(
'click'
,
this
.
setDeviceMotionIOS
,
this
);
}
else
{
...
...
@@ -28,6 +29,7 @@ export default class DevicemotionController extends cc.Component {
(
DeviceMotionEvent
as
any
).
requestPermission
()
.
then
(
permissionState
=>
{
if
(
permissionState
===
'granted'
)
{
Global
.
deviceMotionPermission
=
true
;
this
.
setDeviceMotion
();
}
else
{
console
.
log
(
'Không được cấp quyền sử dụng DeviceMotion'
);
...
...
assets/scripts/Global.ts
View file @
82bcc33b
export
class
Global
{
public
static
deviceMotionPermission
:
boolean
=
false
;
public
static
getRandomTimeSkew
()
{
return
Math
.
random
()
*
0.05
+
0.03
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment