Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
middleLayer_for_NJ
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
middleLayer_for_NJ
Commits
ffa2fa93
Commit
ffa2fa93
authored
May 25, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat:
parent
6dd244b5
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
81 deletions
+98
-81
util.ts
assets/middleLayer_for_NJ/script/util.ts
+98
-81
No files found.
assets/middleLayer_for_NJ/script/util.ts
View file @
ffa2fa93
...
@@ -94,13 +94,13 @@ export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
...
@@ -94,13 +94,13 @@ export function getScaleRateBy2Node(baseNode, targetNode, maxFlag = true) {
}
}
}
}
export
function
getDistance
(
start
,
end
)
{
export
function
getDistance
(
start
,
end
)
{
var
pos
=
cc
.
v2
(
start
.
x
-
end
.
x
,
start
.
y
-
end
.
y
);
var
pos
=
cc
.
v2
(
start
.
x
-
end
.
x
,
start
.
y
-
end
.
y
);
var
dis
=
Math
.
sqrt
(
pos
.
x
*
pos
.
x
+
pos
.
y
*
pos
.
y
);
var
dis
=
Math
.
sqrt
(
pos
.
x
*
pos
.
x
+
pos
.
y
*
pos
.
y
);
return
dis
;
return
dis
;
}
}
export
function
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
export
function
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
if
(
audio_url
)
{
if
(
audio_url
)
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
)
=>
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
)
=>
{
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
...
@@ -114,21 +114,21 @@ export function playAudioByUrl(audio_url, cb=null) {
...
@@ -114,21 +114,21 @@ export function playAudioByUrl(audio_url, cb=null) {
}
}
export
function
btnClickAnima
(
btn
,
time
=
0.15
,
rate
=
1.05
)
{
export
function
btnClickAnima
(
btn
,
time
=
0.15
,
rate
=
1.05
)
{
btn
.
tmpScale
=
btn
.
scale
;
btn
.
tmpScale
=
btn
.
scale
;
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
()
=>
{
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,
()
=>
{
cc
.
tween
(
btn
)
cc
.
tween
(
btn
)
.
to
(
time
/
2
,
{
scale
:
btn
.
scale
*
rate
})
.
to
(
time
/
2
,
{
scale
:
btn
.
scale
*
rate
})
.
start
()
.
start
()
})
})
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
()
=>
{
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_CANCEL
,
()
=>
{
cc
.
tween
(
btn
)
cc
.
tween
(
btn
)
.
to
(
time
/
2
,
{
scale
:
btn
.
tmpScale
})
.
to
(
time
/
2
,
{
scale
:
btn
.
tmpScale
})
.
start
()
.
start
()
})
})
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
()
=>
{
btn
.
on
(
cc
.
Node
.
EventType
.
TOUCH_END
,
()
=>
{
cc
.
tween
(
btn
)
cc
.
tween
(
btn
)
.
to
(
time
/
2
,
{
scale
:
btn
.
tmpScale
})
.
to
(
time
/
2
,
{
scale
:
btn
.
tmpScale
})
.
start
()
.
start
()
})
})
}
}
...
@@ -179,7 +179,7 @@ export async function asyncDelay(time) {
...
@@ -179,7 +179,7 @@ export async function asyncDelay(time) {
try
{
try
{
cc
.
tween
(
cc
.
find
(
'
Canvas
'
))
cc
.
tween
(
cc
.
find
(
'
Canvas
'
))
.
delay
(
time
)
.
delay
(
time
)
.
call
(()
=>
{
.
call
(()
=>
{
resolve
(
null
);
resolve
(
null
);
})
})
.
start
();
.
start
();
...
@@ -505,6 +505,23 @@ export function jumpToCourseWare(courseWareId: number) {
...
@@ -505,6 +505,23 @@ export function jumpToCourseWare(courseWareId: number) {
}
}
}
}
export
function
buttonOnceClick
(
button
:
cc
.
Node
,
callback
:
Function
,
scale
=
1.1
)
{
button
.
once
(
'
click
'
,
()
=>
{
if
(
button
[
'
cantClick
'
])
{
return
;
}
button
[
'
cantClick
'
]
=
true
;
cc
.
tween
(
button
)
.
to
(
0.1
,
{
scale
:
scale
})
.
to
(
0.1
,
{
scale
:
1.0
})
.
call
(()
=>
{
button
[
'
cantClick
'
]
=
false
;
callback
&&
callback
();
})
.
start
();
});
}
export
function
buttonOnClick
(
button
:
cc
.
Node
,
callback
:
Function
,
scale
=
1.1
)
{
export
function
buttonOnClick
(
button
:
cc
.
Node
,
callback
:
Function
,
scale
=
1.1
)
{
button
.
on
(
'
click
'
,
()
=>
{
button
.
on
(
'
click
'
,
()
=>
{
if
(
button
[
'
cantClick
'
])
{
if
(
button
[
'
cantClick
'
])
{
...
...
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