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
Hide 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{
...
@@ -38,19 +38,19 @@ export default class MenuController extends Controller{
await
this
.
view
.
updateData
(
this
.
model
);
await
this
.
view
.
updateData
(
this
.
model
);
this
.
view
.
open
();
this
.
view
.
open
();
let
gameData
=
this
.
model
.
getItem
(
this
.
stageIdx
);
//
let gameData=this.model.getItem(this.stageIdx);
let
words
=
gameData
.
words
.
split
(
""
);
//
let words=gameData.words.split("");
let
answers
=
gameData
.
answers
.
split
(
""
);
//
let answers=gameData.answers.split("");
let
itemAudio
=
gameData
.
audio_url
;
//
let itemAudio=gameData.audio_url;
this
.
answers
=
new
Array
();
this
.
answers
=
new
Array
();
cc
.
log
(
words
);
//
cc.log(words);
cc
.
log
(
answers
);
//
cc.log(answers);
let
colorBlocks
=
this
.
view
.
colorItems1
;
let
colorBlocks
=
this
.
view
.
colorItems1
;
for
(
let
i
=
0
;
i
<
colorBlocks
.
length
;
i
++
){
for
(
let
i
=
0
;
i
<
colorBlocks
.
length
;
i
++
){
cc
.
log
(
colorBlocks
[
i
].
name
);
cc
.
log
(
colorBlocks
[
i
].
name
);
let
word
=
colorBlocks
[
i
].
getComponentInChildren
(
cc
.
Label
);
//
let word=colorBlocks[i].getComponentInChildren(cc.Label);
word
.
string
=
words
[
i
];
//
word.string=words[i];
colorBlocks
[
i
].
color
=
cc
.
Color
.
WHITE
;
colorBlocks
[
i
].
color
=
cc
.
Color
.
WHITE
;
// colorBlocks[i].getComponent(cc.Sprite).trim=true;
// colorBlocks[i].getComponent(cc.Sprite).trim=true;
colorBlocks
[
i
].
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,()
=>
{
colorBlocks
[
i
].
on
(
cc
.
Node
.
EventType
.
TOUCH_START
,()
=>
{
...
@@ -62,30 +62,46 @@ export default class MenuController extends Controller{
...
@@ -62,30 +62,46 @@ export default class MenuController extends Controller{
{
{
return
;
return
;
}
}
// this.onClickBlock(i,answers);
let
result
=
answers
.
findIndex
((
item
)
=>
{
this
.
answers
.
push
(
i
.
toString
());
return
item
==
i
.
toString
();
let
color
=
new
cc
.
Color
();
});
color
.
fromHEX
(
this
.
colorCur
);
cc
.
log
(
"
i:
"
+
i
+
"
,result:
"
+
result
)
colorBlocks
[
i
].
color
=
color
;
if
(
result
==-
1
){
// cc.Color.fromHEX(colorBlocks[i].color,+"#"+this.colorCur);
this
.
onWrong
();
this
.
onRight
();
}
else
{
// let flag=0;
this
.
answers
[
result
]
=
i
.
toString
();
// for(let i=0;i<this.answers.length;i++){
let
color
=
new
cc
.
Color
();
// if(this.answers[i]==answers[i]){
color
.
fromHEX
(
this
.
colorCur
);
// flag++;
colorBlocks
[
i
].
color
=
color
;
// }
// cc.Color.fromHEX(colorBlocks[i].color,+"#"+this.colorCur);
// }
this
.
onRight
();
(
this
.
answers
.
length
>=
colorBlocks
.
length
)
&&
this
.
finish
();
let
flag
=
0
;
// // this.onClickBlock(i,answers);
for
(
let
i
=
0
;
i
<
this
.
answers
.
length
;
i
++
){
// let result=answers.findIndex((item)=>{
if
(
this
.
answers
[
i
]
==
answers
[
i
]){
// return item==i.toString();
flag
++
;
// });
}
// cc.log("i:"+i+",result:"+result)
}
// if(result==-1){
(
flag
>=
answers
.
length
)
&&
this
.
finish
();
// 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
);
colorBlocks
[
i
].
_hitTest
=
this
.
_hitTest
.
bind
(
this
);
}
}
...
@@ -119,10 +135,10 @@ export default class MenuController extends Controller{
...
@@ -119,10 +135,10 @@ export default class MenuController extends Controller{
}
}
private
enter
(){
private
enter
(){
let
gameData
=
this
.
model
.
getItem
(
this
.
stageIdx
);
//
let gameData=this.model.getItem(this.stageIdx);
let
itemAudio
=
gameData
.
audio_url
;
//
let itemAudio=gameData.audio_url;
AppFacade
.
getMgr
(
SoundMgr
).
playEffectByUrl
(
itemAudio
);
//
AppFacade.getMgr(SoundMgr).playEffectByUrl(itemAudio);
//
AppFacade.getMgr(SoundMgr).playEffectByUrl(this.model.getStartAudio());
AppFacade
.
getMgr
(
SoundMgr
).
playEffectByUrl
(
this
.
model
.
getStartAudio
());
this
.
playDragonBoneAnimation
(
this
.
catAni
,
"
begin
"
,
1
,()
=>
{
this
.
playDragonBoneAnimation
(
this
.
catAni
,
"
begin
"
,
1
,()
=>
{
this
.
playDragonBoneAnimation
(
this
.
catAni
,
"
normal
"
,
-
1
);
this
.
playDragonBoneAnimation
(
this
.
catAni
,
"
normal
"
,
-
1
);
});
});
...
@@ -160,9 +176,9 @@ export default class MenuController extends Controller{
...
@@ -160,9 +176,9 @@ export default class MenuController extends Controller{
{
{
item
.
color
=
cc
.
Color
.
WHITE
item
.
color
=
cc
.
Color
.
WHITE
}
}
let
w
=
item
.
getComponentInChildren
(
cc
.
Label
);
//
let w=item.getComponentInChildren(cc.Label);
w
.
string
=
word
.
string
;
//
w.string=word.string;
w
.
node
.
color
=
cc
.
Color
.
BLACK
;
//
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{
...
@@ -50,13 +50,13 @@ export default class MenuModel extends Model{
return
this
.
data
;
return
this
.
data
;
}
}
public
getItems
(){
//
public getItems(){
return
this
.
data
.
items
;
//
return this.data.items;
}
//
}
public
getItem
(
idx
:
number
){
//
public getItem(idx:number){
return
this
.
data
.
items
[
idx
];
//
return this.data.items[idx];
}
//
}
public
getStartAudio
(){
public
getStartAudio
(){
return
this
.
data
.
startAudio
;
return
this
.
data
.
startAudio
;
...
...
assets/Coloring/script/Game/MenuView.ts
View file @
c32115d9
...
@@ -66,8 +66,8 @@ export default class MenuView extends UIFullView{
...
@@ -66,8 +66,8 @@ export default class MenuView extends UIFullView{
protected
async
onUpdateData
(
model
:
MenuModel
){
protected
async
onUpdateData
(
model
:
MenuModel
){
let
images
:{
img
:
string
}[]
=
model
.
getImages
();
let
images
:{
img
:
string
}[]
=
model
.
getImages
();
let
bg1
=
this
.
getChildComp
(
"
main_area/paint/
alligator
"
,
cc
.
Sprite
);
let
bg1
=
this
.
getChildComp
(
"
main_area/paint/
bg_img
"
,
cc
.
Sprite
);
let
bg2
=
this
.
getChildComp
(
"
paint2/
alligator
"
,
cc
.
Sprite
);
let
bg2
=
this
.
getChildComp
(
"
paint2/
bg_img
"
,
cc
.
Sprite
);
bg1
.
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
(
model
.
getBG
());
bg1
.
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
(
model
.
getBG
());
bg2
.
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
(
model
.
getBG
());
bg2
.
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
(
model
.
getBG
());
...
@@ -78,9 +78,9 @@ export default class MenuView extends UIFullView{
...
@@ -78,9 +78,9 @@ export default class MenuView extends UIFullView{
this
.
colorItems2
=
new
Array
();
this
.
colorItems2
=
new
Array
();
let
colorArea2
=
this
.
paint2
;
let
colorArea2
=
this
.
paint2
;
let
gameData
=
model
.
getItem
(
model
.
stageIdx
);
//
let gameData=model.getItem(model.stageIdx);
let
words
=
gameData
.
words
.
split
(
""
);
//
let words=gameData.words.split("");
let
pos
=
gameData
.
pos
;
//
let pos=gameData.pos;
for
(
let
i
=
0
;
i
<
images
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
images
.
length
;
i
++
)
{
let
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
({
url
:
images
[
i
].
img
})
let
spriteFrame
=
await
UIUtil
.
getSpriteByUrl
({
url
:
images
[
i
].
img
})
...
@@ -89,32 +89,30 @@ export default class MenuView extends UIFullView{
...
@@ -89,32 +89,30 @@ export default class MenuView extends UIFullView{
item1
.
group
=
"
camera
"
;
item1
.
group
=
"
camera
"
;
let
sprite1
:
cc
.
Sprite
=
this
.
addCCComp
(
item1
,
cc
.
Sprite
);
let
sprite1
:
cc
.
Sprite
=
this
.
addCCComp
(
item1
,
cc
.
Sprite
);
sprite1
.
spriteFrame
=
spriteFrame
;
sprite1
.
spriteFrame
=
spriteFrame
;
let
wordNode1
=
GameUtil
.
createNode
(
"
word
"
,
item1
);
//
let wordNode1=GameUtil.createNode("word",item1);
wordNode1
.
x
=
pos
[
i
][
0
];
//
wordNode1.x= pos[i][0];
wordNode1
.
y
=
pos
[
i
][
1
];
//
wordNode1.y=pos[i][1];
wordNode1
.
color
=
cc
.
Color
.
BLACK
;
//
wordNode1.color=cc.Color.BLACK;
let
label1
:
cc
.
Label
=
this
.
addCCComp
(
wordNode1
,
cc
.
Label
);
//
let label1:cc.Label=this.addCCComp(wordNode1,cc.Label);
label1
.
string
=
words
[
i
];
//
label1.string=words[i];
label1
.
font
=
model
.
getFont
();
//
label1.font=model.getFont();
label1
.
fontSize
=
80
;
//
label1.fontSize=80;
label1
.
lineHeight
=
80
;
//
label1.lineHeight=80;
this
.
colorItems1
[
i
]
=
sprite1
.
node
;
this
.
colorItems1
[
i
]
=
sprite1
.
node
;
let
item2
=
GameUtil
.
createNode
(
"
img
"
+
1
,
colorArea2
);
let
item2
=
GameUtil
.
createNode
(
"
img
"
+
1
,
colorArea2
);
item2
.
group
=
"
camera
"
item2
.
group
=
"
camera
"
let
sprite2
:
cc
.
Sprite
=
this
.
addCCComp
(
item2
,
cc
.
Sprite
);
let
sprite2
:
cc
.
Sprite
=
this
.
addCCComp
(
item2
,
cc
.
Sprite
);
sprite2
.
spriteFrame
=
spriteFrame
;
sprite2
.
spriteFrame
=
spriteFrame
;
let
wordNode2
=
GameUtil
.
createNode
(
"
word
"
,
item2
);
// let wordNode2=GameUtil.createNode("word",item2);
wordNode2
.
anchorX
=
0
;
// wordNode2.x=pos[i][0];
// wordNode2.y=pos[i][1];
wordNode2
.
x
=
pos
[
i
][
0
];
// wordNode2.color=cc.Color.BLACK;
wordNode2
.
y
=
pos
[
i
][
1
];
// let label2:cc.Label=this.addCCComp(wordNode2,cc.Label);
wordNode2
.
color
=
cc
.
Color
.
BLACK
;
// label2.string=words[i];
let
label2
:
cc
.
Label
=
this
.
addCCComp
(
wordNode2
,
cc
.
Label
);
// label2.font=model.getFont();
label2
.
string
=
words
[
i
];
// label2.fontSize=80;
label2
.
font
=
model
.
getFont
();
// label2.lineHeight=80;
label2
.
fontSize
=
80
;
label2
.
lineHeight
=
80
;
this
.
colorItems2
[
i
]
=
sprite2
.
node
;
this
.
colorItems2
[
i
]
=
sprite2
.
node
;
}
}
}
}
...
...
assets/Coloring/script/defaultData.js
View file @
c32115d9
export
const
defaultData
=
export
const
defaultData
=
{
{
"
items
"
:
[
//
"items": [
{
//
{
"
words
"
:
"
FdFFf
"
,
//
"words": "FdFFf",
"
answers
"
:
"
0
234
"
,
// "answers": "01
234",
"
audio_url
"
:
"
http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3
"
,
//
"audio_url": "http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3",
"
pos
"
:[
//
"pos":[
[
-
425.989
,
-
6.456
],
//
[-425.989,-6.456],
[
-
37.043
,
195.708
],
//
[-37.043,195.708],
[
151.487
,
-
129.498
],
//
[151.487,-129.498],
[
570.348
,
200
],
//
[570.348,200],
[
617.5
,
43.247
]
//
[617.5,43.247]
]
//
]
},
//
},
{
//
{
"
words
"
:
"
aAcBaCbA
"
,
//
"words": "aAcBaCbA",
"
answers
"
:
"
0147
"
,
//
"answers": "0147",
"
audio_url
"
:
"
http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3
"
//
"audio_url": "http://staging-teach.cdn.ireadabc.com/18bf8207ddea222c9b82c68f2549dadc.mp3"
},
//
},
],
//
],
"
startAudio
"
:
"
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
"
,
"
waitAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/46cba1330608d848239ec6a68bb4707e.mp3
"
,
"
finishAudio
"
:
"
http://staging-teach.cdn.ireadabc.com/b3260e3d6972cc59b345f573aaab4290.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