Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Coloring_OL
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
Coloring_OL
Commits
094842f9
Commit
094842f9
authored
Mar 25, 2022
by
张世斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.提交
parent
cb95af13
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
240 additions
and
20 deletions
+240
-20
Coloring_OL.fire
assets/Coloring_OL/scene/Coloring_OL.fire
+5
-5
Coloring_OL.js
assets/Coloring_OL/scene/Coloring_OL.js
+31
-15
MyCocosSceneComponent.ts
assets/Coloring_OL/script/MyCocosSceneComponent.ts
+195
-0
MyCocosSceneComponent.ts.meta
assets/Coloring_OL/script/MyCocosSceneComponent.ts.meta
+9
-0
No files found.
assets/Coloring_OL/scene/Coloring_OL.fire
View file @
094842f9
...
@@ -5650,8 +5650,8 @@
...
@@ -5650,8 +5650,8 @@
"_color": {
"_color": {
"__type__": "cc.Color",
"__type__": "cc.Color",
"r": 255,
"r": 255,
"g":
0
,
"g":
255
,
"b":
0
,
"b":
255
,
"a": 255
"a": 255
},
},
"_contentSize": {
"_contentSize": {
...
@@ -8025,8 +8025,8 @@
...
@@ -8025,8 +8025,8 @@
},
},
"_contentSize": {
"_contentSize": {
"__type__": "cc.Size",
"__type__": "cc.Size",
"width":
1636
,
"width":
679
,
"height":
1600
"height":
451
},
},
"_anchorPoint": {
"_anchorPoint": {
"__type__": "cc.Vec2",
"__type__": "cc.Vec2",
...
@@ -9886,7 +9886,7 @@
...
@@ -9886,7 +9886,7 @@
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
"__uuid__": "eca5d2f2-8ef6-41c2-bbe6-f9c79d09c432"
}
}
],
],
"_srcBlendFactor":
1
,
"_srcBlendFactor":
770
,
"_dstBlendFactor": 771,
"_dstBlendFactor": 771,
"_spriteFrame": {
"_spriteFrame": {
"__uuid__": "96c0dd06-35f7-44c6-bcf9-85e895eb711e"
"__uuid__": "96c0dd06-35f7-44c6-bcf9-85e895eb711e"
...
...
assets/Coloring_OL/scene/Coloring_OL.js
View file @
094842f9
...
@@ -2,11 +2,12 @@ import { onHomeworkFinish, RandomInt, playAudio, playDragonBoneAnimation, getSpr
...
@@ -2,11 +2,12 @@ import { onHomeworkFinish, RandomInt, playAudio, playDragonBoneAnimation, getSpr
import
{
defaultData
}
from
"
../script/defaultData
"
;
import
{
defaultData
}
from
"
../script/defaultData
"
;
import
{
GameServer
}
from
"
../script/server
"
;
import
{
GameServer
}
from
"
../script/server
"
;
import
{
NetworkHelper
}
from
"
../script/NetworkHelper
"
;
import
{
NetworkHelper
}
from
"
../script/NetworkHelper
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
cc
.
Class
({
cc
.
Class
({
extends
:
cc
.
Component
,
extends
:
MyCocosSceneComponent
,
//
cc.Component,
properties
:
{
properties
:
{
paint
:
{
paint
:
{
...
@@ -262,7 +263,6 @@ cc.Class({
...
@@ -262,7 +263,6 @@ cc.Class({
async
initAlligator
(
parent
)
{
async
initAlligator
(
parent
)
{
for
(
let
i
=
0
;
i
<
this
.
data
.
images
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
this
.
data
.
images
.
length
;
i
++
){
let
image
=
this
.
data
.
images
[
i
];
let
image
=
this
.
data
.
images
[
i
];
cc
.
log
(
image
.
img
);
let
tooth
=
await
this
.
getSprNodeByUrl
(
image
.
img
);
let
tooth
=
await
this
.
getSprNodeByUrl
(
image
.
img
);
parent
.
addChild
(
tooth
);
parent
.
addChild
(
tooth
);
// tooth.color = cc.Color.WHITE;
// tooth.color = cc.Color.WHITE;
...
@@ -289,7 +289,7 @@ cc.Class({
...
@@ -289,7 +289,7 @@ cc.Class({
}
}
node
.
teeth
=
teeth
;
node
.
teeth
=
teeth
;
cc
.
log
(
parent
.
name
+
"
_bind:
"
+
node
.
teeth
.
length
);
this
.
log
(
parent
.
name
+
"
_bind:
"
+
node
.
teeth
.
length
);
return
node
;
return
node
;
},
},
...
@@ -558,13 +558,13 @@ cc.Class({
...
@@ -558,13 +558,13 @@ cc.Class({
// if (this.server) {
// if (this.server) {
// this.server.onPlayerJoin(event);
// this.server.onPlayerJoin(event);
// }
// }
cc
.
log
(
"
playerJoin
"
,
(
event
));
this
.
log
(
"
playerJoin
"
,
(
event
));
this
.
onPlayerJoin
(
event
.
data
);
this
.
onPlayerJoin
(
event
.
data
);
});
});
nh
.
on
(
'
playerLeave
'
,
(
event
)
=>
{
nh
.
on
(
'
playerLeave
'
,
(
event
)
=>
{
cc
.
log
(
"
playerLeave
"
+
JSON
.
stringify
(
event
));
this
.
log
(
"
playerLeave
"
+
JSON
.
stringify
(
event
));
});
});
nh
.
on
(
'
gameStart
'
,
(
event
)
=>
{
nh
.
on
(
'
gameStart
'
,
(
event
)
=>
{
...
@@ -708,16 +708,26 @@ cc.Class({
...
@@ -708,16 +708,26 @@ cc.Class({
},
},
getOneItem
(
teethDataArr
,
uuid
)
{
async
getOneItem
(
teethDataArr
,
uuid
)
{
const
mainArea
=
cc
.
find
(
'
Canvas/bg/main_area_small
'
);
const
mainArea
=
cc
.
find
(
'
Canvas/bg/main_area_small
'
);
const
item
=
cc
.
instantiate
(
mainArea
);
const
item
=
cc
.
instantiate
(
mainArea
);
item
.
active
=
true
;
item
.
active
=
true
;
const
paint
=
cc
.
find
(
'
paint
'
,
item
)
const
paint
=
cc
.
find
(
'
paint
'
,
item
)
let
spriteFrame
=
await
this
.
getSpriteFrimeByUrl
(
this
.
data
.
bg
);
let
bg1
=
paint
.
getChildByName
(
"
alligator_img
"
);
bg1
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
spriteFrame
;
const
alligator
=
this
.
bindAlligator
(
paint
);
const
alligator
=
this
.
bindAlligator
(
paint
);
alligator
.
destroyAllChildren
();
if
(
teethDataArr
&&
teethDataArr
.
length
>
0
)
{
if
(
teethDataArr
&&
teethDataArr
.
length
>
0
)
{
for
(
let
i
=
0
;
i
<
teethDataArr
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
teethDataArr
.
length
;
i
++
)
{
alligator
.
teeth
[
i
].
color
=
new
cc
.
Color
().
fromHEX
(
teethDataArr
[
i
].
color
);
let
image
=
this
.
data
.
images
[
i
];
let
tooth
=
await
this
.
getSprNodeByUrl
(
image
.
img
);
tooth
.
color
=
new
cc
.
Color
().
fromHEX
(
teethDataArr
[
i
].
color
);
alligator
.
addChild
(
tooth
);
// alligator.teeth[i].color = new cc.Color().fromHEX(teethDataArr[i].color);
// alligator.teeth[i].word.node.color = new cc.Color().fromHEX(teethDataArr[i].wordColor);
// alligator.teeth[i].word.node.color = new cc.Color().fromHEX(teethDataArr[i].wordColor);
// alligator.teeth[i].word.string = teethDataArr[i].word;
// alligator.teeth[i].word.string = teethDataArr[i].word;
}
}
...
@@ -926,7 +936,7 @@ cc.Class({
...
@@ -926,7 +936,7 @@ cc.Class({
async
fillAiData
()
{
async
fillAiData
()
{
const
c
=
window
.
courseware
;
const
c
=
window
.
courseware
;
//
cc
.log("fillAiData:",c);
//
this
.log("fillAiData:",c);
if
(
!
c
)
{
if
(
!
c
)
{
return
;
return
;
}
}
...
@@ -1150,7 +1160,7 @@ cc.Class({
...
@@ -1150,7 +1160,7 @@ cc.Class({
},
},
resultItemArr
:
null
,
resultItemArr
:
null
,
initOtherPlayerItem
()
{
async
initOtherPlayerItem
()
{
console
.
log
(
'
in initOtherPlayerItem
'
)
console
.
log
(
'
in initOtherPlayerItem
'
)
...
@@ -1159,17 +1169,23 @@ cc.Class({
...
@@ -1159,17 +1169,23 @@ cc.Class({
const
itemArr
=
[];
const
itemArr
=
[];
// const resultArr = this.gameEndData;
// const resultArr = this.gameEndData;
let
s
=
0
;
let
a
=
[
[
0
,
0
],[
1
,
0
],[
2
,
0
],
[
0
,
1
],[
1
,
1
],[
2
,
1
]
];
for
(
let
key
in
this
.
gameEndData
)
{
for
(
let
key
in
this
.
gameEndData
)
{
const
itemData
=
this
.
gameEndData
[
key
];
const
itemData
=
this
.
gameEndData
[
key
];
const
id
=
key
;
const
id
=
key
;
const
{
teethDataArr
}
=
itemData
const
{
teethDataArr
}
=
itemData
const
item
=
this
.
getOneItem
(
teethDataArr
,
id
);
this
.
log
(
teethDataArr
.
length
+
"
_endData:
"
+
JSON
.
stringify
(
teethDataArr
));
const
item
=
await
this
.
getOneItem
(
teethDataArr
,
id
);
item
.
x
=
(
item
.
width
+
50
)
*
a
[
s
][
0
];
item
.
y
=
(
item
.
height
+
50
)
*
a
[
s
][
1
];
s
++
;
itemArr
.
push
(
item
);
itemArr
.
push
(
item
);
this
.
resultLayer
.
addChild
(
item
);
this
.
resultLayer
.
addChild
(
item
);
...
@@ -1390,7 +1406,7 @@ cc.Class({
...
@@ -1390,7 +1406,7 @@ cc.Class({
let
spriteFrame
=
await
this
.
getSpriteFrimeByUrl
(
this
.
data
.
bg
);
let
spriteFrame
=
await
this
.
getSpriteFrimeByUrl
(
this
.
data
.
bg
);
let
bg1
=
this
.
paint
.
getChildByName
(
"
alligator_img
"
);
let
bg1
=
this
.
paint
.
getChildByName
(
"
alligator_img
"
);
cc
.
log
(
"
bg:
"
+
bg1
.
name
);
this
.
log
(
"
bg:
"
+
bg1
.
name
);
bg1
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
spriteFrame
;
bg1
.
getComponent
(
cc
.
Sprite
).
spriteFrame
=
spriteFrame
;
let
bg2
=
this
.
paint2
.
getChildByName
(
"
alligator_img
"
);
let
bg2
=
this
.
paint2
.
getChildByName
(
"
alligator_img
"
);
...
...
assets/Coloring_OL/script/MyCocosSceneComponent.ts
0 → 100644
View file @
094842f9
import
{
defaultData
}
from
"
./defaultData
"
;
export
class
MyCocosSceneComponent
extends
cc
.
Component
{
// 生命周期 onLoad
onLoad
()
{
this
.
initSceneData
();
this
.
initSize
();
}
_imageResList
=
null
;
_audioResList
=
null
;
_animaResList
=
null
;
initSceneData
()
{
this
.
_imageResList
=
[];
this
.
_audioResList
=
[];
this
.
_animaResList
=
[];
}
_designSize
=
null
;
// 设计分辨率
_frameSize
=
null
;
// 屏幕分辨率
_mapScaleMin
=
null
;
// 场景中常用缩放(取大值)
_mapScaleMax
=
null
;
// 场景中常用缩放(取小值)
_cocosScale
=
null
;
// cocos 自缩放 (较少用到)
initSize
()
{
// 注意cc.winSize只有在适配后(修改fitHeight/fitWidth后)才能获取到正确的值,因此使用cc.getFrameSize()来获取初始的屏幕大小
let
screen_size
=
cc
.
view
.
getFrameSize
().
width
/
cc
.
view
.
getFrameSize
().
height
let
design_size
=
cc
.
Canvas
.
instance
.
designResolution
.
width
/
cc
.
Canvas
.
instance
.
designResolution
.
height
let
f
=
screen_size
>=
design_size
cc
.
Canvas
.
instance
.
fitHeight
=
f
cc
.
Canvas
.
instance
.
fitWidth
=
!
f
const
frameSize
=
cc
.
view
.
getFrameSize
();
this
.
_frameSize
=
frameSize
;
this
.
_designSize
=
cc
.
view
.
getDesignResolutionSize
();
let
sx
=
cc
.
winSize
.
width
/
frameSize
.
width
;
let
sy
=
cc
.
winSize
.
height
/
frameSize
.
height
;
this
.
_cocosScale
=
Math
.
min
(
sx
,
sy
);
sx
=
frameSize
.
width
/
this
.
_designSize
.
width
;
sy
=
frameSize
.
height
/
this
.
_designSize
.
height
;
this
.
_mapScaleMin
=
Math
.
min
(
sx
,
sy
)
*
this
.
_cocosScale
;
this
.
_mapScaleMax
=
Math
.
max
(
sx
,
sy
)
*
this
.
_cocosScale
;
cc
.
director
[
'
_scene
'
].
width
=
frameSize
.
width
;
cc
.
director
[
'
_scene
'
].
height
=
frameSize
.
height
;
}
data
=
null
;
// 生命周期 start
start
()
{
let
getData
=
this
.
getData
.
bind
(
this
);
if
(
window
&&
(
<
any
>
window
).
courseware
)
{
getData
=
(
<
any
>
window
).
courseware
.
getData
;
}
getData
((
data
)
=>
{
console
.
log
(
'
data:
'
,
data
);
this
.
data
=
data
||
this
.
getDefaultData
();
this
.
data
=
JSON
.
parse
(
JSON
.
stringify
(
this
.
data
))
this
.
preloadItem
()
// courseInScreen
// scene.distroy() courseOutScreen
})
}
getData
(
func
)
{
if
(
window
&&
(
<
any
>
window
).
courseware
)
{
(
<
any
>
window
).
courseware
.
getData
(
func
,
'
scene
'
);
return
;
}
const
middleLayer
=
cc
.
find
(
'
middleLayer
'
);
if
(
middleLayer
)
{
const
middleLayerComponent
=
middleLayer
.
getComponent
(
'
middleLayer
'
);
middleLayerComponent
.
getData
(
func
);
return
;
}
func
(
this
.
getDefaultData
());
}
getDefaultData
()
{
return
defaultData
;
}
preloadItem
()
{
this
.
addPreloadImage
();
this
.
addPreloadAudio
();
this
.
addPreloadAnima
();
this
.
preload
();
}
addPreloadImage
()
{
}
addPreloadAudio
()
{
}
addPreloadAnima
()
{
}
preload
()
{
const
preloadArr
=
this
.
_imageResList
.
concat
(
this
.
_audioResList
).
concat
(
this
.
_animaResList
);
cc
.
assetManager
.
loadAny
(
preloadArr
,
null
,
null
,
(
err
,
data
)
=>
{
if
(
window
&&
window
[
"
air
"
])
{
// window["air"].onCourseInScreen = (next) => {
// window["air"].isCourseInScreen = true;
// this.onLoadEnd();
// next();
// };
this
.
onLoadEnd
();
window
[
"
air
"
].
hideAirClassLoading
();
}
else
{
this
.
onLoadEnd
();
}
cc
.
debug
.
setDisplayStats
(
false
);
});
}
log
(
str
)
{
const
node
=
cc
.
find
(
'
middleLayer
'
);
if
(
node
){
node
.
getComponent
(
'
middleLayer
'
).
log
(
str
);
}
else
{
cc
.
log
(
str
);
}
}
onLoadEnd
()
{
}
// ------------------------------------------------
getSprNode
(
resName
)
{
const
sf
=
cc
.
find
(
'
Canvas/res/img/
'
+
resName
).
getComponent
(
cc
.
Sprite
).
spriteFrame
;
const
node
=
new
cc
.
Node
();
node
.
addComponent
(
cc
.
Sprite
).
spriteFrame
=
sf
;
return
node
;
}
getSpriteFrimeByUrl
(
url
,
cb
)
{
cc
.
loader
.
load
({
url
},
(
err
,
img
)
=>
{
const
spriteFrame
=
new
cc
.
SpriteFrame
(
img
)
if
(
cb
)
{
cb
(
spriteFrame
);
}
})
}
getSprNodeByUrl
(
url
,
cb
)
{
const
node
=
new
cc
.
Node
();
const
spr
=
node
.
addComponent
(
cc
.
Sprite
);
this
.
getSpriteFrimeByUrl
(
url
,
(
sf
)
=>
{
spr
.
spriteFrame
=
sf
;
if
(
cb
)
{
cb
(
node
);
}
})
}
playAudioByUrl
(
audio_url
,
cb
=
null
)
{
if
(
audio_url
)
{
cc
.
assetManager
.
loadRemote
(
audio_url
,
(
err
,
audioClip
)
=>
{
const
audioId
=
cc
.
audioEngine
.
play
(
audioClip
,
false
,
0.8
);
if
(
cb
)
{
cc
.
audioEngine
.
setFinishCallback
(
audioId
,
()
=>
{
cb
();
});
}
});
}
}
}
\ No newline at end of file
assets/Coloring_OL/script/MyCocosSceneComponent.ts.meta
0 → 100644
View file @
094842f9
{
"ver": "1.0.8",
"uuid": "9d32bbd2-e78d-49dd-b6f3-3ea1f8501678",
"isPlugin": false,
"loadPluginInWeb": true,
"loadPluginInNative": true,
"loadPluginInEditor": false,
"subMetas": {}
}
\ No newline at end of file
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