Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
X
xy_camera
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
xy_camera
Commits
9427ee84
Commit
9427ee84
authored
Aug 15, 2022
by
liujiangnan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 主体功能
parent
73ff5aa0
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
498 additions
and
150 deletions
+498
-150
picload.mp3
assets/xy_camera/audios/picload.mp3
+0
-0
picload.mp3.meta
assets/xy_camera/audios/picload.mp3.meta
+7
-0
success.mp3
assets/xy_camera/audios/success.mp3
+0
-0
success.mp3.meta
assets/xy_camera/audios/success.mp3.meta
+2
-2
upload.mp3
assets/xy_camera/audios/upload.mp3
+0
-0
upload.mp3.meta
assets/xy_camera/audios/upload.mp3.meta
+2
-2
xy_camera.fire
assets/xy_camera/scene/xy_camera.fire
+340
-135
xy_camera.ts
assets/xy_camera/scene/xy_camera.ts
+98
-10
defaultData.ts
assets/xy_camera/script/defaultData.ts
+1
-1
util.ts
assets/xy_camera/script/util.ts
+48
-0
No files found.
assets/xy_camera/audios/picload.mp3
0 → 100644
View file @
9427ee84
File added
assets/xy_camera/audios/picload.mp3.meta
0 → 100644
View file @
9427ee84
{
"ver": "2.0.1",
"uuid": "d3f3a66c-51cd-4fcf-bc2b-8d424c4918d1",
"downloadMode": 0,
"duration": 2.319563,
"subMetas": {}
}
\ No newline at end of file
assets/xy_camera/audios/success.mp3
View file @
9427ee84
No preview for this file type
assets/xy_camera/audios/success.mp3.meta
View file @
9427ee84
{
"ver": "2.0.1",
"uuid": "4
becf611-d0bc-4bd8-9bc9-b4d66646ada9
",
"uuid": "4
641cae0-0d7a-4008-bc0e-ddf209310d28
",
"downloadMode": 0,
"duration":
0.301724
,
"duration":
5.172245
,
"subMetas": {}
}
\ No newline at end of file
assets/xy_camera/audios/upload.mp3
View file @
9427ee84
No preview for this file type
assets/xy_camera/audios/upload.mp3.meta
View file @
9427ee84
{
"ver": "2.0.1",
"uuid": "4
641cae0-0d7a-4008-bc0e-ddf209310d28
",
"uuid": "4
becf611-d0bc-4bd8-9bc9-b4d66646ada9
",
"downloadMode": 0,
"duration":
5.172245
,
"duration":
0.301724
,
"subMetas": {}
}
\ No newline at end of file
assets/xy_camera/scene/xy_camera.fire
View file @
9427ee84
This diff is collapsed.
Click to expand it.
assets/xy_camera/scene/xy_camera.ts
View file @
9427ee84
import
{
buttonOnClick
,
buttonOnceClick
,
getSpriteFrimeByUrl
,
asyncLoadDragonBoneAnime
,
asyncDelay
}
from
"
../script/util
"
;
import
{
buttonOnClick
,
buttonOnceClick
,
getSpriteFrimeByUrl
,
asyncGetSpriteFrimeByUrl
,
playAudioByUrl
,
asyncLoadDragonBoneAnime
,
asyncDelay
,
setNetImg
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
...
...
@@ -7,6 +9,21 @@ const { ccclass, property } = cc._decorator;
export
default
class
SceneComponent
extends
MyCocosSceneComponent
{
@
property
(
cc
.
Node
)
startNode
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
page_view
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
tip_label
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
tip_left
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
tip_right
:
cc
.
Node
=
null
;
addPreloadImage
()
{
// TODO 根据自己的配置预加载图片资源
}
...
...
@@ -56,7 +73,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
async
onLoadEnd
()
{
// TODO 加载完成后的逻辑写在这里, 下面的代码仅供参考
this
.
initData
();
this
.
initView
();
await
this
.
initView
();
await
this
.
asyncDrawAnswer
();
this
.
initListener
();
}
...
...
@@ -68,8 +85,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
picture_url
=
null
;
initView
()
{
async
initView
()
{
this
.
initBg
();
await
this
.
initTips
();
window
[
"
cameraHandler
"
].
takePictureCallback
=
(
err
,
url
)
=>
{
if
(
err
)
{
console
.
log
(
err
);
...
...
@@ -84,6 +102,7 @@ export default class SceneComponent extends MyCocosSceneComponent {
getSpriteFrimeByUrl
(
url
,
(
frame
)
=>
{
pic
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
frame
;
pic
.
active
=
true
;
this
.
playLocalAudio
(
"
picload
"
);
this
.
hideLoading
();
});
}
...
...
@@ -95,9 +114,56 @@ export default class SceneComponent extends MyCocosSceneComponent {
bgNode
.
scale
=
this
.
_mapScaleMax
;
}
async
initTips
()
{
if
(
this
.
data
.
tipSwitch
==
0
)
{
cc
.
find
(
"
btn_start
"
,
this
.
node
).
active
=
false
;
return
;
}
this
.
startNode
.
active
=
true
;
const
data
:
any
=
await
setNetImg
(
cc
.
find
(
"
s_group/startbg
"
,
this
.
startNode
),
this
.
data
.
tipBg
,
{
w
:
0
,
h
:
0
},
false
);
this
.
page_view
.
width
=
data
.
w
-
240
;
this
.
page_view
.
height
=
data
.
h
-
200
;
this
.
page_view
.
x
=
-
(
data
.
w
/
2
);
this
.
data
.
tipPage
.
forEach
((
dt
,
idx
)
=>
{
let
desc
=
cc
.
instantiate
(
this
.
tip_label
);
desc
.
getComponent
(
cc
.
Label
).
string
=
dt
.
title
;
desc
.
width
=
this
.
page_view
.
width
;
desc
.
height
=
this
.
page_view
.
height
-
40
;
this
.
page_view
.
getComponent
(
cc
.
PageView
).
addPage
(
desc
);
desc
.
active
=
true
;
desc
[
"
data
"
]
=
dt
;
})
this
.
updataTipArrow
();
const
btnStart
=
cc
.
find
(
"
btn_start
"
,
this
.
node
);
await
asyncLoadDragonBoneAnime
(
btnStart
,
{
skeJsonData
:
this
.
data
.
imgAni
.
ske
,
texJsonData
:
this
.
data
.
imgAni
.
tex
,
texPngData
:
this
.
data
.
imgAni
.
png
});
const
animaNode
=
btnStart
[
'
animaNode
'
];
const
db
=
animaNode
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
let
anis
=
db
.
getAnimationNames
(
"
armatureName
"
);
db
.
playAnimation
(
anis
[
0
],
0
);
}
updataTipArrow
()
{
let
index
=
this
.
page_view
.
getComponent
(
cc
.
PageView
).
getCurrentPageIndex
();
let
pages
=
this
.
page_view
.
getComponent
(
cc
.
PageView
).
getPages
();
this
.
tip_left
.
active
=
pages
.
length
>
0
&&
index
>
0
;
this
.
tip_right
.
active
=
pages
.
length
>
0
&&
index
<
pages
.
length
-
1
;
let
page
=
pages
[
index
];
if
(
page
)
playAudioByUrl
(
page
[
"
data
"
].
audio
);
}
initListener
()
{
const
btn
=
cc
.
find
(
`Canvas/border/upload`
);
buttonOnClick
(
btn
,
()
=>
{
this
.
playLocalAudio
(
"
upload
"
);
this
.
showLoading
();
window
[
"
cameraHandler
"
].
openCamera
();
});
...
...
@@ -119,6 +185,31 @@ export default class SceneComponent extends MyCocosSceneComponent {
console
.
log
(
"
==切换下一页==
"
);
}
});
const
btnStart
=
cc
.
find
(
"
btn_start
"
,
this
.
node
);
btnStart
.
on
(
'
click
'
,
()
=>
{
if
(
btnStart
[
'
cantClick
'
])
{
return
;
}
btnStart
[
'
cantClick
'
]
=
true
;
this
.
startNode
.
active
=
true
;
let
start_ske
=
btnStart
[
'
animaNode
'
];
cc
.
tween
(
start_ske
).
to
(
0.2
,
{
scale
:
1
}).
start
();
this
.
updataTipArrow
();
});
buttonOnClick
(
cc
.
find
(
"
s_group/startbg/btn_close
"
,
this
.
startNode
),
()
=>
{
cc
.
audioEngine
.
stopAll
();
const
btnStart
=
cc
.
find
(
"
btn_start
"
,
this
.
node
);
let
start_ske
=
btnStart
[
'
animaNode
'
];
cc
.
tween
(
start_ske
).
to
(
0.2
,
{
scale
:
0.3
}).
call
(()
=>
{
cc
.
find
(
"
btn_start
"
,
this
.
node
)[
'
cantClick
'
]
=
false
;
}).
start
();
this
.
page_view
.
getComponent
(
cc
.
PageView
).
setCurrentPageIndex
(
0
);
this
.
startNode
.
active
=
false
;
});
}
async
showFinal
()
{
...
...
@@ -133,12 +224,13 @@ export default class SceneComponent extends MyCocosSceneComponent {
texJsonData
:
this
.
data
.
endImgAni
.
tex
,
texPngData
:
this
.
data
.
endImgAni
.
png
});
const
animaNode
=
f_group
[
'
animaNode
'
];
const
db
=
animaNode
.
getComponent
(
dragonBones
.
ArmatureDisplay
);
let
anis
=
db
.
getAnimationNames
(
"
armatureName
"
);
db
.
playAnimation
(
anis
[
0
],
0
);
this
.
playLocalAudio
(
"
success
"
);
final
.
active
=
true
;
let
desc
=
cc
.
find
(
"
desc
"
,
f_group
);
let
final_title
=
cc
.
find
(
"
final_title
"
,
f_group
);
...
...
@@ -161,13 +253,9 @@ export default class SceneComponent extends MyCocosSceneComponent {
}
playLocalAudio
(
audioName
)
{
cc
.
audioEngine
.
stopAll
();
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
return
new
Promise
((
resolve
,
reject
)
=>
{
const
id
=
cc
.
audioEngine
.
playEffect
(
audio
.
clip
,
false
);
cc
.
audioEngine
.
setFinishCallback
(
id
,
()
=>
{
resolve
(
id
);
});
})
cc
.
audioEngine
.
playEffect
(
audio
.
clip
,
false
);
}
onLeave
(
cb
)
{
...
...
assets/xy_camera/script/defaultData.ts
View file @
9427ee84
...
...
@@ -19,7 +19,7 @@ export const defaultData = {
"
tipPage
"
:
[
{
"
title
"
:
"
这么小的院子里,居然同时有一间书房和一间书院,这家人可真喜欢读书啊。
"
,
"
audio
"
:
""
"
audio
"
:
"
https://staging-teach.cdn.ireadabc.com/c03129693e6cabf061661fba349fa031.mp3
"
}
],
"
title
"
:
""
,
...
...
assets/xy_camera/script/util.ts
View file @
9427ee84
...
...
@@ -143,6 +143,54 @@ export function getSpriteFrimeByUrl(url, cb) {
})
}
export
function
asyncGetSpriteFrimeByUrl
(
url
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
cc
.
loader
.
load
({
url
},
(
err
,
img
)
=>
{
if
(
err
)
{
reject
(
err
);
return
;
}
const
spriteFrame
=
new
cc
.
SpriteFrame
(
img
)
resolve
(
spriteFrame
);
})
});
}
export
function
setNetImg
(
item
,
res
,
{
w
,
h
},
custom
=
true
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
item
)
return
console
.
warn
(
"
图片更换失败,传入了错误的item
"
);
let
node
=
item
.
node
?
item
.
node
:
item
;
if
(
!
res
)
{
if
(
node
)
node
.
active
=
false
;
return
console
.
warn
(
"
图片更换失败,传入了错误的res
"
);
}
if
(
!
node
)
return
console
.
warn
(
"
图片更换失败,传入了错误的item
"
);
if
(
node
.
net_url
==
res
)
return
;
node
.
active
=
false
;
//
cc
.
loader
.
load
({
url
:
res
},
(
err
,
texture
)
=>
{
if
(
err
&&
!
texture
)
return
resolve
(
console
.
warn
(
'
loading loadRes warn->
'
+
texture
));
if
(
!
cc
.
isValid
(
node
))
return
console
.
info
(
"
节点已销毁
"
);
let
nw
=
node
.
width
=
texture
.
width
;
let
nh
=
node
.
height
=
texture
.
height
;
let
component
=
node
.
getComponent
(
cc
.
Sprite
);
let
spriteFrame
=
new
cc
.
SpriteFrame
(
texture
);
component
.
spriteFrame
=
spriteFrame
;
node
.
net_url
=
res
;
if
(
!
cc
.
isValid
(
node
))
return
console
.
info
(
"
节点已销毁
"
);
if
(
!
node
)
return
console
.
warn
(
"
节点已销毁
"
);
if
(
w
&&
h
&&
custom
)
{
let
scaleX
=
w
/
nw
;
let
scaleY
=
h
/
nh
;
let
scale
=
scaleX
<=
scaleY
?
scaleX
:
scaleY
;
node
.
width
=
nw
*
scale
;
node
.
height
=
nh
*
scale
;
}
node
.
active
=
true
;
resolve
({
w
:
nw
,
h
:
nh
});
});
})
}
export
function
getSprNode
(
resName
)
{
const
sf
=
cc
.
find
(
'
Canvas/res/img/
'
+
resName
).
getComponent
(
cc
.
Sprite
).
spriteFrame
;
const
node
=
new
cc
.
Node
();
...
...
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