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
5f99a3b4
Commit
5f99a3b4
authored
Apr 01, 2025
by
Vũ Gia Vương
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add debug ios
parent
a9807606
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
337 additions
and
193 deletions
+337
-193
main.fire
assets/main.fire
+291
-192
HuController.ts
assets/scripts/GamePlay/HuController.ts
+46
-1
No files found.
assets/main.fire
View file @
5f99a3b4
This diff is collapsed.
Click to expand it.
assets/scripts/GamePlay/HuController.ts
View file @
5f99a3b4
...
@@ -14,9 +14,11 @@ export default class HuController extends cc.Component {
...
@@ -14,9 +14,11 @@ export default class HuController extends cc.Component {
private
_count
=
0
;
private
_count
=
0
;
private
_isShake
=
false
;
private
_isShake
=
false
;
private
_track
:
TrackEntry
=
null
;
private
_track
:
TrackEntry
=
null
;
private
_debug
:
cc
.
Label
=
null
;
protected
onLoad
():
void
{
protected
onLoad
():
void
{
this
.
_spine
=
this
.
node
.
getComponent
(
sp
.
Skeleton
);
this
.
_spine
=
this
.
node
.
getComponent
(
sp
.
Skeleton
);
this
.
_debug
=
this
.
node
.
getComponentInChildren
(
cc
.
Label
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
this
.
onTouchStart
,
this
);
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
)
this
.
node
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
this
.
onTouchEnd
,
this
)
...
@@ -28,11 +30,53 @@ export default class HuController extends cc.Component {
...
@@ -28,11 +30,53 @@ export default class HuController extends cc.Component {
this
.
initBottle
();
this
.
initBottle
();
});
});
this
.
scheduleOnce
(
this
.
setDeviceMotion
,
2
);
if
(
cc
.
sys
.
os
===
cc
.
sys
.
OS_IOS
)
{
this
.
setDeviceMotionIOS
();
}
else
{
this
.
scheduleOnce
(
this
.
setDeviceMotion
,
2
);
}
this
.
initBottle
();
this
.
initBottle
();
}
}
private
setDeviceMotionIOS
()
{
const
debug
=
(
text
:
string
)
=>
{
this
.
_debug
.
string
=
text
;
}
debug
(
'setDeviceMotionIOS'
);
if
(
window
.
DeviceMotionEvent
)
{
// Yêu cầu quyền truy cập trên iOS (từ iOS 13+)
if
(
typeof
(
DeviceMotionEvent
as
any
).
requestPermission
===
'function'
)
{
debug
(
'requestPermission'
);
(
DeviceMotionEvent
as
any
).
requestPermission
()
.
then
(
permissionState
=>
{
debug
(
'requestPermission: '
+
permissionState
);
if
(
permissionState
===
'granted'
)
{
debug
(
'granted setDeviceMotion'
);
this
.
setDeviceMotion
();
}
else
{
debug
(
'Không được cấp quyền sử dụng DeviceMotion'
);
console
.
log
(
'Không được cấp quyền sử dụng DeviceMotion'
);
}
})
.
catch
(
e
=>
{
console
.
error
(
e
);
debug
(
'Không được cấp quyền sử dụng DeviceMotion'
);
});
}
else
{
debug
(
'Không hỗ trợ requestPermission'
);
this
.
setDeviceMotion
();
}
}
else
{
debug
(
'Trình duyệt không hỗ trợ DeviceMotion API'
);
console
.
log
(
'Trình duyệt không hỗ trợ DeviceMotion API'
);
}
}
private
initBottle
()
{
private
initBottle
()
{
this
.
_spine
.
setAnimation
(
1
,
"Rotate"
,
false
);
this
.
_spine
.
setAnimation
(
1
,
"Rotate"
,
false
);
this
.
_spine
.
timeScale
=
this
.
_pointStart
?
0
:
0.5
;
this
.
_spine
.
timeScale
=
this
.
_pointStart
?
0
:
0.5
;
...
@@ -50,6 +94,7 @@ export default class HuController extends cc.Component {
...
@@ -50,6 +94,7 @@ export default class HuController extends cc.Component {
private
onTouchEnd
():
void
{
private
onTouchEnd
():
void
{
this
.
scheduleOnce
(()
=>
{
this
.
scheduleOnce
(()
=>
{
this
.
_spine
.
timeScale
=
0
;
this
.
_spine
.
timeScale
=
0
;
console
.
log
(
'this._track.trackTime'
,
this
.
_track
.
trackTime
)
if
(
this
.
_track
.
trackTime
<
0
)
{
if
(
this
.
_track
.
trackTime
<
0
)
{
this
.
_track
.
trackTime
=
this
.
_track
.
animationEnd
-
1
e
-
9
;
this
.
_track
.
trackTime
=
this
.
_track
.
animationEnd
-
1
e
-
9
;
}
}
...
...
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