Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
anim_insert_ques
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
anim_insert_ques
Commits
03da6730
Commit
03da6730
authored
Apr 26, 2022
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 精简
parent
8029fd2d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
199 additions
and
141 deletions
+199
-141
anim_insert_ques.ts
assets/anim_insert_ques/scene/anim_insert_ques.ts
+197
-139
util.ts
assets/anim_insert_ques/script/util.ts
+2
-2
No files found.
assets/anim_insert_ques/scene/anim_insert_ques.ts
View file @
03da6730
import
{
asyncDelay
,
callMiddleLayerFunction
,
onHomeworkFinish
,
playAudio
}
from
"
../script/util
"
;
import
{
asyncDelay
,
asyncLoadDragonBoneAnime
,
callMiddleLayerFunction
,
onHomeworkFinish
,
playAudio
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -13,7 +13,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
addPreloadAudio
()
{
// TODO 根据自己的配置预加载音频资源
this
.
_audioResList
.
push
({
url
:
(
this
.
data
.
lrcData
&&
this
.
data
.
lrcData
.
audio_url
)
||
''
});
this
.
_audioResList
.
push
({
url
:
(
this
.
data
.
lrcData
&&
this
.
data
.
lrcData
.
audio_url
)
||
''
});
}
addPreloadAnima
()
{
...
...
@@ -27,8 +27,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
this
.
_animaResList
.
push
({
url
:
this
.
data
.
skeJsonData
.
url
||
''
});
this
.
_animaResList
.
push
({
url
:
this
.
data
.
texJsonData
.
url
||
''
});
this
.
_animaResList
.
push
({
url
:
this
.
data
.
texPngData
.
url
||
''
});
this
.
_animaResList
.
push
({
url
:
this
.
data
.
texJsonData
.
url
||
''
});
this
.
_animaResList
.
push
({
url
:
this
.
data
.
texPngData
.
url
||
''
});
}
onLoadEnd
()
{
...
...
@@ -44,8 +44,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
isAnimLoaded
=
false
;
const
checkStart
=
()
=>
{
console
.
log
(
'
in checkStart:
'
,
isDataLoaded
)
console
.
log
(
'
in isAnimLoaded:
'
,
isAnimLoaded
)
console
.
log
(
'
in checkStart:
'
,
isDataLoaded
)
console
.
log
(
'
in isAnimLoaded:
'
,
isAnimLoaded
)
if
(
isDataLoaded
&&
isAnimLoaded
)
{
window
[
"
air
"
].
hideAirClassLoading
();
...
...
@@ -144,7 +144,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
return
;
}
for
(
let
i
=
0
;
i
<
lyrics
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
lyrics
.
length
;
i
++
)
{
const
data
=
lyrics
[
i
].
data
;
if
(
!
data
)
{
...
...
@@ -155,10 +155,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
let
duration
=
0
;
if
(
i
!=
lyrics
.
length
-
1
)
{
duration
=
lyrics
[
i
+
1
].
time
-
lyrics
[
i
].
time
;
duration
=
lyrics
[
i
+
1
].
time
-
lyrics
[
i
].
time
;
}
this
.
textArr
.
push
({
data
,
time
,
duration
});
this
.
textArr
.
push
({
data
,
time
,
duration
});
}
}
...
...
@@ -179,7 +179,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
initView
()
{
console
.
log
(
'
in initView
'
)
console
.
log
(
'
in initView
'
)
if
(
this
.
jumpData
)
{
this
.
junpAnim
();
...
...
@@ -216,9 +216,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
let
disFrame
=
maxDisFrame
;
for
(
let
i
=
1
;
i
<
arr
.
length
;
i
++
)
{
for
(
let
i
=
1
;
i
<
arr
.
length
;
i
++
)
{
const
curDis
=
(
arr
[
i
].
text
-
arr
[
i
-
1
].
text
)
/
2
;
const
curDis
=
(
arr
[
i
].
text
-
arr
[
i
-
1
].
text
)
/
2
;
if
(
disFrame
>
curDis
)
{
disFrame
=
curDis
;
}
...
...
@@ -260,10 +260,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
lightLeft
.
rotation
=
45
;
lightLeft
.
opacity
=
0
;
cc
.
tween
(
lightLeft
)
.
to
(
1
,
{
rotation
:
-
45
},
{
easing
:
"
cubicOut
"
})
.
to
(
1
,
{
rotation
:
-
45
},
{
easing
:
"
cubicOut
"
})
.
start
();
cc
.
tween
(
lightLeft
)
.
to
(
0.5
,
{
opacity
:
255
})
.
to
(
0.5
,
{
opacity
:
255
})
.
start
();
const
lightRight
=
this
.
getSprNode
(
'
light
'
);
...
...
@@ -276,10 +276,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
lightRight
.
rotation
=
-
45
;
lightRight
.
opacity
=
0
;
cc
.
tween
(
lightRight
)
.
to
(
1
,
{
rotation
:
45
},
{
easing
:
"
cubicOut
"
})
.
to
(
1
,
{
rotation
:
45
},
{
easing
:
"
cubicOut
"
})
.
start
();
cc
.
tween
(
lightRight
)
.
to
(
0.5
,
{
opacity
:
255
})
.
to
(
0.5
,
{
opacity
:
255
})
.
start
();
...
...
@@ -306,7 +306,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
startAudioEnd
();
}));
})
.
to
(
1.5
,
{
y
:
0
},
{
easing
:
"
elasticOut
"
})
.
to
(
1.5
,
{
y
:
0
},
{
easing
:
"
elasticOut
"
})
.
start
();
this
.
title
=
title
...
...
@@ -334,13 +334,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
sprNode
.
opacity
=
0
;
cc
.
tween
(
sprNode
)
.
to
(
time
/
10
,
{
opacity
:
255
})
.
to
(
time
/
10
,
{
opacity
:
255
})
.
start
();
cc
.
tween
(
sprNode
)
.
to
(
0.8
*
time
,
{
scale
:
this
.
_mapScaleMin
},
{
easing
:
'
elasticOut
'
})
.
to
(
0.8
*
time
,
{
scale
:
this
.
_mapScaleMin
},
{
easing
:
'
elasticOut
'
})
.
delay
(
0
*
time
)
.
to
(
0.2
*
time
,
{
opacity
:
0
})
.
to
(
0.2
*
time
,
{
opacity
:
0
})
.
start
();
}
...
...
@@ -373,9 +373,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
async
hideStartView
()
{
const
hideSpr
=
(
sprNode
,
cb
=
null
)
=>
{
const
hideSpr
=
(
sprNode
,
cb
=
null
)
=>
{
cc
.
tween
(
sprNode
)
.
to
(
0.3
,
{
opacity
:
0
})
.
to
(
0.3
,
{
opacity
:
0
})
.
call
(()
=>
{
sprNode
.
active
=
false
;
cb
&&
cb
();
...
...
@@ -426,7 +426,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
callMiddleLayerFunction
(
'
PSQS_jump_to_question
'
,
{
step
:
id
},
null
)
callMiddleLayerFunction
(
'
PSQS_jump_to_question
'
,
{
step
:
id
},
null
)
return
;
}
...
...
@@ -472,7 +472,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
console
.
log
(
'
PSQS_show_rabbit 2
'
)
callMiddleLayerFunction
(
'
PSQS_jump_to_question
'
,
{
step
:
id
},
null
)
callMiddleLayerFunction
(
'
PSQS_jump_to_question
'
,
{
step
:
id
},
null
)
// })
})
}
...
...
@@ -539,7 +539,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
jumpAudio
(
id
)
{
console
.
log
(
'
in jumpAudio id:
'
,
id
);
const
stepData
=
this
.
data
.
stepArr
[
id
-
1
];
const
stepData
=
this
.
data
.
stepArr
[
id
-
1
];
console
.
log
(
'
stepData:
'
,
stepData
);
const
time
=
stepData
.
text
/
this
.
data
.
frame
;
...
...
@@ -620,13 +620,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
back
.
scale
=
0.3
;
back
.
opacity
=
0
cc
.
tween
(
back
)
.
to
(
0.9
,
{
scale
:
this
.
_mapScaleMin
,
opacity
:
255
},
{
easing
:
'
elasticOut
'
})
.
to
(
0.9
,
{
scale
:
this
.
_mapScaleMin
,
opacity
:
255
},
{
easing
:
'
elasticOut
'
})
.
start
();
back
.
addComponent
(
cc
.
Button
);
back
.
on
(
'
click
'
,
()
=>
{
console
.
log
(
'
click back
'
)
callMiddleLayerFunction
(
'
PSQS_exit_book
'
,
null
,
()
=>
{});
callMiddleLayerFunction
(
'
PSQS_exit_book
'
,
null
,
()
=>
{
});
})
}
...
...
@@ -641,7 +641,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
console
.
log
(
'
in animPlayEnd 2
'
)
// setTimeout(() => {
callMiddleLayerFunction
(
'
PSQS_play_animate_over
'
,
null
,
()
=>
{
})
callMiddleLayerFunction
(
'
PSQS_play_animate_over
'
,
null
,
()
=>
{
})
// }, 100);
// callMiddleLayerFunction('PSQS_play_animate_over', this.animaNode, () => {})
// })
...
...
@@ -684,11 +684,69 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
}
async
setOneAnima1
(
data
,
cb
)
{
if
(
!
data
.
texPngData
)
{
return
}
asyncLoadDragonBoneAnime
(
this
.
canvas
,
data
);
const
animaNode
=
this
.
canvas
.
animaNode
;
animaNode
.
scale
=
this
.
_mapScaleMax
;
if
(
this
.
data
.
scale
)
{
animaNode
.
scale
*=
this
.
data
.
scale
;
}
const
dragonDisplay
=
animaNode
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
dragonDisplay
.
armatureName
=
dragonDisplay
.
getArmatureNames
()[
0
];
const
animationName
=
dragonDisplay
.
getAnimationNames
()[
0
];
dragonDisplay
.
playAnimation
(
animationName
,
1
);
dragonDisplay
.
timeScale
=
0
;
dragonDisplay
.
off
(
dragonBones
.
EventObject
.
FRAME_EVENT
)
dragonDisplay
.
on
(
dragonBones
.
EventObject
.
FRAME_EVENT
,
(
event
)
=>
{
console
.
log
(
'
in frameEventFunc
'
)
if
(
this
.
playTimes
>
0
)
{
this
.
animChangeStep
(
event
.
name
);
}
})
dragonDisplay
.
off
(
dragonBones
.
EventObject
.
COMPLETE
)
dragonDisplay
.
on
(
dragonBones
.
EventObject
.
COMPLETE
,
()
=>
{
console
.
log
(
'
in compFunc
'
)
if
(
this
.
isLast
&&
this
.
playTimes
>
0
)
{
this
.
showGoodjob
();
}
else
{
this
.
animPlayEnd
();
}
})
animaNode
.
off
(
'
touchstart
'
)
animaNode
.
on
(
'
touchstart
'
,
(
e
)
=>
{
const
pos
=
e
.
getLocation
();
const
x
=
pos
.
x
// - e.currentTarget.width / 2;
const
y
=
pos
.
y
// - e.currentTarget.height / 2;
const
newPos
=
animaNode
.
convertToNodeSpaceAR
(
cc
.
v2
(
x
,
y
));
console
.
log
(
'
X:
'
,
Math
.
round
(
newPos
.
x
));
console
.
log
(
'
Y:
'
,
Math
.
round
(
newPos
.
y
));
});
this
.
dragonDisplay
=
dragonDisplay
;
this
.
animaNode
=
animaNode
;
cb
&&
cb
();
}
dragonDisplay
;
animaNode
;
maxTexture
;
setOneAnima
(
data
,
cb
)
{
this
.
setOneAnima1
(
data
,
cb
);
return
;
console
.
log
(
'
setOneAnima 1
'
)
...
...
@@ -824,14 +882,14 @@ export default class SceneComponent extends MyCocosSceneComponent {
// dragonDisplay = animaNode.addComponent(dragonBones.ArmatureDisplay);
console
.
log
(
'
dragonDisplay =
'
+
typeof
(
dragonDisplay
));
console
.
log
(
'
dragonDisplay =
'
+
typeof
(
dragonDisplay
));
dragonDisplay
.
dragonAtlasAsset
=
atlas
;
console
.
log
(
'
汪汪汪 1
'
)
dragonDisplay
.
dragonAsset
=
asset
;
console
.
log
(
'
汪汪汪 2
'
)
console
.
log
(
'
type:
'
+
typeof
(
asset
.
dragonBonesJson
));
console
.
log
(
'
type:
'
+
typeof
(
asset
.
dragonBonesJson
));
let
json
=
JSON
.
parse
(
asset
.
dragonBonesJson
);
console
.
log
(
'
json:
'
,
json
);
...
...
@@ -933,8 +991,8 @@ export default class SceneComponent extends MyCocosSceneComponent {
const
y
=
pos
.
y
// - e.currentTarget.height / 2;
const
newPos
=
animaNode
.
convertToNodeSpaceAR
(
cc
.
v2
(
x
,
y
));
console
.
log
(
'
X:
'
,
Math
.
round
(
newPos
.
x
));
console
.
log
(
'
Y:
'
,
Math
.
round
(
newPos
.
y
));
console
.
log
(
'
X:
'
,
Math
.
round
(
newPos
.
x
));
console
.
log
(
'
Y:
'
,
Math
.
round
(
newPos
.
y
));
}
animaNode
.
off
(
'
touchstart
'
)
animaNode
.
on
(
'
touchstart
'
,
touchFunc
)
...
...
@@ -956,7 +1014,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
delayRelease
(
oldAtlas
,
oldAsset
,
delteItem
=
null
)
{
delayRelease
(
oldAtlas
,
oldAsset
,
delteItem
=
null
)
{
setTimeout
(()
=>
{
...
...
@@ -1008,7 +1066,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
getCurTextObj
()
{
const
data
=
this
.
textArr
[
this
.
textArrIndex
];
if
(
data
)
{
this
.
textArrIndex
++
;
this
.
textArrIndex
++
;
}
return
data
;
}
...
...
@@ -1040,18 +1098,18 @@ export default class SceneComponent extends MyCocosSceneComponent {
this
.
textLabel
.
node
.
opacity
=
0
;
this
.
textLabel
.
string
=
`<outline color=white width=4>
${
textObj
.
data
}
</outline>`
if
(
textObj
.
duration
)
{
if
(
textObj
.
duration
)
{
this
.
textLabel
.
curTween
=
cc
.
tween
(
this
.
textLabel
.
node
)
.
to
(
0.2
,
{
opacity
:
255
},
{
easing
:
'
sineOut
'
})
.
delay
(
textObj
.
duration
)
.
to
(
0.2
,
{
opacity
:
255
},
{
easing
:
'
sineOut
'
})
.
delay
(
textObj
.
duration
)
.
call
(()
=>
{
this
.
curTextObj
=
null
;
})
.
to
(
0.1
,
{
opacity
:
0
})
.
to
(
0.1
,
{
opacity
:
0
})
.
start
();
}
else
{
this
.
textLabel
.
curTween
=
cc
.
tween
(
this
.
textLabel
.
node
)
.
to
(
0.2
,
{
opacity
:
255
},
{
easing
:
'
sineOut
'
})
.
to
(
0.2
,
{
opacity
:
255
},
{
easing
:
'
sineOut
'
})
.
start
();
}
...
...
@@ -1059,7 +1117,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
getTextLabel
()
{
const
richTextNode
=
new
cc
.
Node
();
richTextNode
.
y
=
-
this
.
canvas
.
height
/
2
+
20
*
this
.
_mapScaleMin
;
richTextNode
.
y
=
-
this
.
canvas
.
height
/
2
+
20
*
this
.
_mapScaleMin
;
richTextNode
.
opacity
=
0
;
richTextNode
.
anchorY
=
0
;
richTextNode
.
scale
=
this
.
_mapScaleMin
;
...
...
@@ -1091,7 +1149,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
update
(
dt
)
{
update
(
dt
)
{
this
.
checkShowText
();
}
...
...
assets/anim_insert_ques/script/util.ts
View file @
03da6730
...
...
@@ -238,7 +238,7 @@ export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJs
Promise
.
all
([
loadTexture
,
loadTexJsonData
,
loadSkeJsonData
]).
then
(([
texture
,
atlasJson
,
dragonBonesJson
])
=>
{
const
atlas
=
new
dragonBones
.
DragonBonesAtlasAsset
();
atlas
.
atlasJson
=
JSON
.
stringify
(
atlasJson
);
atlas
.
texture
=
texture
;
atlas
.
texture
=
<
any
>
texture
;
const
asset
=
new
dragonBones
.
DragonBonesAsset
();
asset
.
dragonBonesJson
=
JSON
.
stringify
(
dragonBonesJson
);
...
...
@@ -246,7 +246,7 @@ export async function asyncLoadDragonBoneAnime(node, { skeJsonData: { url: skeJs
dragonDisplay
.
dragonAtlasAsset
=
atlas
;
dragonDisplay
.
dragonAsset
=
asset
;
let
armatureNames
=
dragonBonesJson
.
armature
.
map
(
data
=>
data
.
name
);
let
armatureNames
=
(
<
any
>
dragonBonesJson
)
.
armature
.
map
(
data
=>
data
.
name
);
if
(
armatureNames
.
length
>
0
)
{
dragonDisplay
.
armatureName
=
armatureNames
[
0
];
...
...
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