Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
Coloring
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
Commits
c32115d9
Commit
c32115d9
authored
Mar 23, 2022
by
张世斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.修复bug
parent
9a5658eb
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
476 additions
and
372 deletions
+476
-372
Coloring.fire
assets/Coloring/scene/Coloring.fire
+373
-283
MenuController.ts
assets/Coloring/script/Game/MenuController.ts
+55
-39
MenuModel.ts
assets/Coloring/script/Game/MenuModel.ts
+6
-6
MenuView.ts
assets/Coloring/script/Game/MenuView.ts
+23
-25
defaultData.js
assets/Coloring/script/defaultData.js
+19
-19
No files found.
assets/Coloring/scene/Coloring.fire
View file @
c32115d9
This diff is collapsed.
Click to expand it.
assets/Coloring/script/Game/MenuController.ts
View file @
c32115d9
...
...
@@ -38,19 +38,19 @@ export default class MenuController extends Controller{
await
this
.
view
.
updateData
(
this
.
model
);
this
.
view
.
open
();
let
gameData
=
this
.
model
.
getItem
(
this
.
stageIdx
);
//
let gameData=this.model.getItem(this.stageIdx);
let
words
=
gameData
.
words
.
split
(
""
);
let
answers
=
gameData
.
answers
.
split
(
""
);
let
itemAudio
=
gameData
.
audio_url
;
//
let words=gameData.words.split("");
//
let answers=gameData.answers.split("");
//
let itemAudio=gameData.audio_url;
this
.
answers
=
new
Array
();
cc
.
log
(
words
);
cc
.
log
(
answers
);
//
cc.log(words);
//
cc.log(answers);
let
colorBlocks
=
this
.
view
.
colorItems1
;
for
(
let
i
=
0
;
i
<
colorBlocks
.
length
;
i
++
){
cc
.
log
(
colorBlocks
[
i
].
name
);
let
word
=
colorBlocks
[
i
].
getComponentInChildren
(
cc
.
Label
);
word
.
string
=
words
[
i
];
//
let word=colorBlocks[i].getComponentInChildren(cc.Label);
//
word.string=words[i];
colorBlocks
[
i
].
color
=
cc
.
Color
.
WHITE
;
// colorBlocks[i].getComponent(cc.Sprite).trim=true;
colorBlocks
[
i
].
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,()
=>
{
...
...
@@ -62,30 +62,46 @@ export default class MenuController extends Controller{
{
return
;
}
// this.onClickBlock(i,answers);
let
result
=
answers
.
findIndex
((
item
)
=>
{
return
item
==
i
.
toString
();
});
cc
.
log
(
"
i:
"
+
i
+
"
,result:
"
+
result
)
if
(
result
==-
1
){
this
.
onWrong
();
}
else
{
this
.
answers
[
result
]
=
i
.
toString
();
this
.
answers
.
push
(
i
.
toString
());
let
color
=
new
cc
.
Color
();
color
.
fromHEX
(
this
.
colorCur
);
colorBlocks
[
i
].
color
=
color
;
// cc.Color.fromHEX(colorBlocks[i].color,+"#"+this.colorCur);
this
.
onRight
();
let
flag
=
0
;
for
(
let
i
=
0
;
i
<
this
.
answers
.
length
;
i
++
){
if
(
this
.
answers
[
i
]
==
answers
[
i
]){
flag
++
;
}
}
(
flag
>=
answers
.
length
)
&&
this
.
finish
();
}
// let flag=0;
// for(let i=0;i<this.answers.length;i++){
// if(this.answers[i]==answers[i]){
// flag++;
// }
// }
(
this
.
answers
.
length
>=
colorBlocks
.
length
)
&&
this
.
finish
();
// // this.onClickBlock(i,answers);
// let result=answers.findIndex((item)=>{
// return item==i.toString();
// });
// cc.log("i:"+i+",result:"+result)
// if(result==-1){
// this.onWrong();
// }
// else{
// this.answers[result]=i.toString();
// let color=new cc.Color();
// color.fromHEX(this.colorCur);
// colorBlocks[i].color=color;
// // cc.Color.fromHEX(colorBlocks[i].color,+"#"+this.colorCur);
// this.onRight();
// let flag=0;
// for(let i=0;i<this.answers.length;i++){
// if(this.answers[i]==answers[i]){
// flag++;
// }
// }
// (flag>=answers.length)&&this.finish();
// }
});
colorBlocks
[
i
].
_hitTest
=
this
.
_hitTest
.
bind
(
this
);
}
...
...
@@ -119,10 +135,10 @@ export default class MenuController extends Controller{
}
private
enter
(){
let
gameData
=
this
.
model
.
getItem
(
this
.
stageIdx
);
let
itemAudio
=
gameData
.
audio_url
;
AppFacade
.
getMgr
(
SoundMgr
).
playEffectByUrl
(
itemAudio
);
//
AppFacade.getMgr(SoundMgr).playEffectByUrl(this.model.getStartAudio());
//
let gameData=this.model.getItem(this.stageIdx);
//
let itemAudio=gameData.audio_url;
//
AppFacade.getMgr(SoundMgr).playEffectByUrl(itemAudio);
AppFacade
.
getMgr
(
SoundMgr
).
playEffectByUrl
(
this
.
model
.
getStartAudio
());
this
.
playDragonBoneAnimation
(
this
.
catAni
,
"
begin
"
,
1
,()
=>
{
this
.
playDragonBoneAnimation
(
this
.
catAni
,
"
normal
"
,
-
1
);
});
...
...
@@ -160,9 +176,9 @@ export default class MenuController extends Controller{
{
item
.
color
=
cc
.
Color
.
WHITE
}
let
w
=
item
.
getComponentInChildren
(
cc
.
Label
);
w
.
string
=
word
.
string
;
w
.
node
.
color
=
cc
.
Color
.
BLACK
;
//
let w=item.getComponentInChildren(cc.Label);
//
w.string=word.string;
//
w.node.color=cc.Color.BLACK;
}
}
...
...
assets/Coloring/script/Game/MenuModel.ts
View file @
c32115d9
...
...
@@ -50,13 +50,13 @@ export default class MenuModel extends Model{
return
this
.
data
;
}
public
getItems
(){
return
this
.
data
.
items
;
}
//
public getItems(){
//
return this.data.items;
//
}
public
getItem
(
idx
:
number
){
return
this
.
data
.
items
[
idx
];
}
//
public getItem(idx:number){
//
return this.data.items[idx];
//
}
public
getStartAudio
(){
return
this
.
data
.
startAudio
;
...
...
assets/Coloring/script/Game/MenuView.ts
View file @
c32115d9
...
...
@@ -66,8 +66,8 @@ export default class MenuView extends UIFullView{
protected
async
onUpdateData
(
model
:
MenuModel
){
let
images
:{
img
:
string
}[]
=
model
.
getImages
();
let
bg1
=
this
.
getChildComp
(
"
main_area/paint/
alligator
"
,
cc
.
Sprite
);
let
bg2
=
this
.
getChildComp
(
"
paint2/
alligator
"
,
cc
.
Sprite
);
let
bg1
=
this
.
getChildComp
(
"
main_area/paint/
bg_img
"
,
cc
.
Sprite
);
let
bg2
=
this
.
getChildComp
(
"
paint2/
bg_img
"
,
cc
.
Sprite
);
bg1
.
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
(
model
.
getBG
());
bg2
.
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
(
model
.
getBG
());
...
...
@@ -78,9 +78,9 @@ export default class MenuView extends UIFullView{
this
.
colorItems2
=
new
Array
();
let
colorArea2
=
this
.
paint2
;
let
gameData
=
model
.
getItem
(
model
.
stageIdx
);
let
words
=
gameData
.
words
.
split
(
""
);
let
pos
=
gameData
.
pos
;
//
let gameData=model.getItem(model.stageIdx);
//
let words=gameData.words.split("");
//
let pos=gameData.pos;
for
(
let
i
=
0
;
i
<
images
.
length
;
i
++
)
{
let
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
({
url
:
images
[
i
].
img
})
...
...
@@ -89,32 +89,30 @@ export default class MenuView extends UIFullView{
item1
.
group
=
"
camera
"
;
let
sprite1
:
cc
.
Sprite
=
this
.
addCCComp
(
item1
,
cc
.
Sprite
);
sprite1
.
spriteFrame
=
spriteFrame
;
let
wordNode1
=
GameUtil
.
createNode
(
"
word
"
,
item1
);
wordNode1
.
x
=
pos
[
i
][
0
];
wordNode1
.
y
=
pos
[
i
][
1
];
wordNode1
.
color
=
cc
.
Color
.
BLACK
;
let
label1
:
cc
.
Label
=
this
.
addCCComp
(
wordNode1
,
cc
.
Label
);
label1
.
string
=
words
[
i
];
label1
.
font
=
model
.
getFont
();
label1
.
fontSize
=
80
;
label1
.
lineHeight
=
80
;
//
let wordNode1=GameUtil.createNode("word",item1);
//
wordNode1.x= pos[i][0];
//
wordNode1.y=pos[i][1];
//
wordNode1.color=cc.Color.BLACK;
//
let label1:cc.Label=this.addCCComp(wordNode1,cc.Label);
//
label1.string=words[i];
//
label1.font=model.getFont();
//
label1.fontSize=80;
//
label1.lineHeight=80;
this
.
colorItems1
[
i
]
=
sprite1
.
node
;
let
item2
=
GameUtil
.
createNode
(
"
img
"
+
1
,
colorArea2
);
item2
.
group
=
"
camera
"
let
sprite2
:
cc
.
Sprite
=
this
.
addCCComp
(
item2
,
cc
.
Sprite
);
sprite2
.
spriteFrame
=
spriteFrame
;
let
wordNode2
=
GameUtil
.
createNode
(
"
word
"
,
item2
);
wordNode2
.
anchorX
=
0
;
wordNode2
.
x
=
pos
[
i
][
0
];
wordNode2
.
y
=
pos
[
i
][
1
];
wordNode2
.
color
=
cc
.
Color
.
BLACK
;
let
label2
:
cc
.
Label
=
this
.
addCCComp
(
wordNode2
,
cc
.
Label
);
label2
.
string
=
words
[
i
];
label2
.
font
=
model
.
getFont
();
label2
.
fontSize
=
80
;
label2
.
lineHeight
=
80
;
// let wordNode2=GameUtil.createNode("word",item2);
// wordNode2.x=pos[i][0];
// wordNode2.y=pos[i][1];
// wordNode2.color=cc.Color.BLACK;
// let label2:cc.Label=this.addCCComp(wordNode2,cc.Label);
// label2.string=words[i];
// label2.font=model.getFont();
// label2.fontSize=80;
// label2.lineHeight=80;
this
.
colorItems2
[
i
]
=
sprite2
.
node
;
}
}
...
...
assets/Coloring/script/defaultData.js
View file @
c32115d9
export
const
defaultData
=
{
"
items
"
:
[
{
"
words
"
:
"
FdFFf
"
,
"
answers
"
:
"
0
234
"
,
"
audio_url
"
:
"
http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3
"
,
"
pos
"
:[
[
-
425.989
,
-
6.456
],
[
-
37.043
,
195.708
],
[
151.487
,
-
129.498
],
[
570.348
,
200
],
[
617.5
,
43.247
]
]
},
{
"
words
"
:
"
aAcBaCbA
"
,
"
answers
"
:
"
0147
"
,
"
audio_url
"
:
"
http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3
"
},
],
//
"items": [
//
{
//
"words": "FdFFf",
// "answers": "01
234",
//
"audio_url": "http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3",
//
"pos":[
//
[-425.989,-6.456],
//
[-37.043,195.708],
//
[151.487,-129.498],
//
[570.348,200],
//
[617.5,43.247]
//
]
//
},
//
{
//
"words": "aAcBaCbA",
//
"answers": "0147",
//
"audio_url": "http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3"
//
},
//
],
"
startAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3
"
,
"
waitAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/46cba1330608d848239ec6a68bb4707e.mp3
"
,
"
finishAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/b3260e3d6972cc59b345f573aaab4290.mp3
"
,
...
...
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