Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fireballoon
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
fireballoon
Commits
354b163b
Commit
354b163b
authored
May 13, 2022
by
Tt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更换图片
parent
e885e1ae
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
290 additions
and
55 deletions
+290
-55
cocos_generator.fire
assets/cocos_generator/scene/cocos_generator.fire
+68
-52
cocos_generator.ts
assets/cocos_generator/scene/cocos_generator.ts
+210
-3
pg.ts
assets/cocos_generator/scene/tool/pg.ts
+12
-0
No files found.
assets/cocos_generator/scene/cocos_generator.fire
View file @
354b163b
...
...
@@ -2551,7 +2551,7 @@
"__id__": 51
}
],
"_active":
fals
e,
"_active":
tru
e,
"_components": [],
"_prefab": null,
"_opacity": 255,
...
...
@@ -2635,8 +2635,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width": 0,
"height": 0
"width":
22
0,
"height":
30
0
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -2647,8 +2647,8 @@
"__type__": "TypedArray",
"ctor": "Float64Array",
"array": [
0
,
0
,
-901.775
,
-724.273
,
0,
0,
0,
...
...
@@ -2757,7 +2757,7 @@
},
{
"__type__": "cc.Node",
"_name": "img_balloon1_
2
",
"_name": "img_balloon1_
1
",
"_objFlags": 0,
"_parent": {
"__id__": 52
...
...
@@ -2780,8 +2780,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
121
,
"height":
304
"width":
214
,
"height":
296
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -2815,7 +2815,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "
1bP3+7o/hNiLnXELiGjZmy
"
"_id": "
0bvPZIQqJFioA2TBeWp0NT
"
},
{
"__type__": "cc.Sprite",
...
...
@@ -2833,7 +2833,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
06bede29-078b-41ff-ab82-1ae30a8beb2
3"
"__uuid__": "
5d9cd65e-d26f-483a-baa1-359e334cba4
3"
},
"_type": 0,
"_sizeMode": 1,
...
...
@@ -2847,11 +2847,11 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "
d2oNDNcYFDBr2XB5hxzdPa
"
"_id": "
bccKxLzjlOAZVP1TBYmpGz
"
},
{
"__type__": "cc.Node",
"_name": "img_balloon1_
1
",
"_name": "img_balloon1_
2
",
"_objFlags": 0,
"_parent": {
"__id__": 52
...
...
@@ -2874,8 +2874,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
214
,
"height":
296
"width":
121
,
"height":
304
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -2909,7 +2909,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "
0bvPZIQqJFioA2TBeWp0NT
"
"_id": "
1bP3+7o/hNiLnXELiGjZmy
"
},
{
"__type__": "cc.Sprite",
...
...
@@ -2927,7 +2927,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
5d9cd65e-d26f-483a-baa1-359e334cba4
3"
"__uuid__": "
06bede29-078b-41ff-ab82-1ae30a8beb2
3"
},
"_type": 0,
"_sizeMode": 1,
...
...
@@ -2941,11 +2941,11 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "
bccKxLzjlOAZVP1TBYmpGz
"
"_id": "
d2oNDNcYFDBr2XB5hxzdPa
"
},
{
"__type__": "cc.Node",
"_name": "img_balloon2_
2
",
"_name": "img_balloon2_
1
",
"_objFlags": 0,
"_parent": {
"__id__": 52
...
...
@@ -2968,8 +2968,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
96
,
"height":
30
8
"width":
213
,
"height":
29
8
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -3003,7 +3003,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "
628hI4r7RJ157RlTRFXX+a
"
"_id": "
efCiMxrHxJqrYQ1mBl6K7z
"
},
{
"__type__": "cc.Sprite",
...
...
@@ -3021,7 +3021,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
49b19388-1ccb-43a5-937f-ee5d81bf4826
"
"__uuid__": "
8aca4c78-aa56-43b8-83c6-deafaaa49230
"
},
"_type": 0,
"_sizeMode": 1,
...
...
@@ -3035,11 +3035,11 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "
1cZ8jCGIJMJ5F1pjGNVHSi
"
"_id": "
66fDgEHMhEHrbUsuFTropu
"
},
{
"__type__": "cc.Node",
"_name": "img_balloon
3_1
",
"_name": "img_balloon
2_2
",
"_objFlags": 0,
"_parent": {
"__id__": 52
...
...
@@ -3062,8 +3062,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
213
,
"height":
296
"width":
96
,
"height":
308
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -3097,7 +3097,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "
72HwOnuDNC/ZbQhgVq8/sN
"
"_id": "
628hI4r7RJ157RlTRFXX+a
"
},
{
"__type__": "cc.Sprite",
...
...
@@ -3115,7 +3115,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
9fd52c45-e86b-49fb-8f4f-a065af330151
"
"__uuid__": "
49b19388-1ccb-43a5-937f-ee5d81bf4826
"
},
"_type": 0,
"_sizeMode": 1,
...
...
@@ -3129,11 +3129,11 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "
83aGa/XelLjIQJC818M/h+
"
"_id": "
1cZ8jCGIJMJ5F1pjGNVHSi
"
},
{
"__type__": "cc.Node",
"_name": "img_balloon3_
2
",
"_name": "img_balloon3_
1
",
"_objFlags": 0,
"_parent": {
"__id__": 52
...
...
@@ -3156,8 +3156,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
134
,
"height":
300
"width":
213
,
"height":
296
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -3191,7 +3191,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "
25y5mOrZhPLImYVLANErD
N"
"_id": "
72HwOnuDNC/ZbQhgVq8/s
N"
},
{
"__type__": "cc.Sprite",
...
...
@@ -3209,7 +3209,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
23efed2a-2ebd-4740-a35a-77113c96d988
"
"__uuid__": "
9fd52c45-e86b-49fb-8f4f-a065af330151
"
},
"_type": 0,
"_sizeMode": 1,
...
...
@@ -3223,11 +3223,11 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "
eeQqMJdTtJRJbewkr2mDYv
"
"_id": "
83aGa/XelLjIQJC818M/h+
"
},
{
"__type__": "cc.Node",
"_name": "img_balloon
4
_2",
"_name": "img_balloon
3
_2",
"_objFlags": 0,
"_parent": {
"__id__": 52
...
...
@@ -3250,8 +3250,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
82
,
"height": 3
42
"width":
134
,
"height": 3
00
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -3285,7 +3285,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "2
99VW01GdI9p2bQjJan73p
"
"_id": "2
5y5mOrZhPLImYVLANErDN
"
},
{
"__type__": "cc.Sprite",
...
...
@@ -3303,7 +3303,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
87c56679-6c0e-4065-bcf1-96abc084a3fc
"
"__uuid__": "
23efed2a-2ebd-4740-a35a-77113c96d988
"
},
"_type": 0,
"_sizeMode": 1,
...
...
@@ -3317,11 +3317,11 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "
cc9/hSVV1B+phh6EfKIkyh
"
"_id": "
eeQqMJdTtJRJbewkr2mDYv
"
},
{
"__type__": "cc.Node",
"_name": "img_balloon
2
_1",
"_name": "img_balloon
4
_1",
"_objFlags": 0,
"_parent": {
"__id__": 52
...
...
@@ -3345,7 +3345,7 @@
"_contentSize": {
"__type__": "cc.Size",
"width": 213,
"height": 29
8
"height": 29
6
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -3379,7 +3379,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "
efCiMxrHxJqrYQ1mBl6K7z
"
"_id": "
adcvdFtD1NBZY38SxVJwaB
"
},
{
"__type__": "cc.Sprite",
...
...
@@ -3397,7 +3397,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
8aca4c78-aa56-43b8-83c6-deafaaa49230
"
"__uuid__": "
cc8c0a98-0497-4965-af17-8b9bc3f55013
"
},
"_type": 0,
"_sizeMode": 1,
...
...
@@ -3411,11 +3411,11 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "
66fDgEHMhEHrbUsuFTropu
"
"_id": "
f5HN9buQVIGLyy+R4762cg
"
},
{
"__type__": "cc.Node",
"_name": "img_balloon4_
1
",
"_name": "img_balloon4_
2
",
"_objFlags": 0,
"_parent": {
"__id__": 52
...
...
@@ -3438,8 +3438,8 @@
},
"_contentSize": {
"__type__": "cc.Size",
"width":
213
,
"height":
296
"width":
82
,
"height":
342
},
"_anchorPoint": {
"__type__": "cc.Vec2",
...
...
@@ -3473,7 +3473,7 @@
"_is3DNode": false,
"_groupIndex": 0,
"groupIndex": 0,
"_id": "
adcvdFtD1NBZY38SxVJwaB
"
"_id": "
299VW01GdI9p2bQjJan73p
"
},
{
"__type__": "cc.Sprite",
...
...
@@ -3491,7 +3491,7 @@
"_srcBlendFactor": 770,
"_dstBlendFactor": 771,
"_spriteFrame": {
"__uuid__": "
cc8c0a98-0497-4965-af17-8b9bc3f55013
"
"__uuid__": "
87c56679-6c0e-4065-bcf1-96abc084a3fc
"
},
"_type": 0,
"_sizeMode": 1,
...
...
@@ -3505,7 +3505,7 @@
"_fillRange": 0,
"_isTrimmedMode": true,
"_atlas": null,
"_id": "
f5HN9buQVIGLyy+R4762cg
"
"_id": "
cc9/hSVV1B+phh6EfKIkyh
"
},
{
"__type__": "cc.Node",
...
...
@@ -6109,6 +6109,22 @@
"__id__": 2
},
"_enabled": true,
"res": {
"__id__": 5
},
"layout_player": null,
"layout_balloon": {
"__id__": 50
},
"item_gun": {
"__id__": 39
},
"item_left": {
"__id__": 51
},
"item_right": {
"__id__": 51
},
"_id": "eaTVUpqahPfZeO9+sUI7RP"
}
]
\ No newline at end of file
assets/cocos_generator/scene/cocos_generator.ts
View file @
354b163b
import
{
asyncDelay
,
onHomeworkFinish
}
from
"
../script/util
"
;
import
{
MyCocosSceneComponent
}
from
"
../script/MyCocosSceneComponent
"
;
import
Game
,
{
GAME_STATE
}
from
"
./tool/Game
"
;
import
Game
,
{
FISH_OUT
,
GAME_STATE
,
Option
}
from
"
./tool/Game
"
;
import
pg
from
"
./tool/pg
"
;
const
{
ccclass
,
property
}
=
cc
.
_decorator
;
export
function
getDegree
(
p1
,
p2
)
{
let
vector
=
p2
.
sub
(
p1
);
let
degree
=
Math
.
atan
(
vector
.
y
/
vector
.
x
)
/
Math
.
PI
*
180
;
if
(
vector
.
x
>=
0
)
{
if
(
vector
.
y
<
0
)
{
degree
+=
360
;
}
}
else
{
if
(
vector
.
y
>
0
)
{
degree
+=
180
;
}
else
{
degree
=
180
+
degree
;
}
}
return
-
(
-
degree
+
90
);
//角度计算方法
}
@
ccclass
export
default
class
SceneComponent
extends
MyCocosSceneComponent
{
...
...
@@ -33,6 +49,19 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
event
.
clear
();
}
@
property
(
cc
.
Node
)
res
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_player
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
layout_balloon
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
item_gun
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
item_left
:
cc
.
Node
=
null
;
@
property
(
cc
.
Node
)
item_right
:
cc
.
Node
=
null
;
_cantouch
=
null
;
initData
()
{
Game
.
getIns
().
init
(
this
.
data
);
...
...
@@ -79,6 +108,10 @@ export default class SceneComponent extends MyCocosSceneComponent {
pg
.
event
.
emit
(
"
game_start
"
);
}
private
count
:
number
;
private
list
:
Option
[];
private
fishs
:
cc
.
Node
[];
gameStart
()
{
Game
.
getIns
().
state
=
GAME_STATE
.
RUNNING
;
//游戏开始小鱼出现等等
...
...
@@ -87,14 +120,188 @@ export default class SceneComponent extends MyCocosSceneComponent {
cc
.
audioEngine
.
stopAllEffects
();
// pg.audio.stopAudio(this.audioId);
}
//开始
//根据数据随机热气球
let
page
=
Game
.
getIns
().
getCurrentPage
();
let
list
=
page
.
optionList
.
concat
();
list
=
JSON
.
parse
(
JSON
.
stringify
(
list
));
list
.
sort
((
A
,
B
)
=>
{
return
Math
.
random
()
<
0.5
});
this
.
list
=
list
;
this
.
count
=
0
;
this
.
lastCount
=
null
;
this
.
fishs
=
[];
this
.
viewFishs
=
[];
this
.
touchFishs
=
[];
//根据顺序生成对应的鱼。
//顺序根据时间来进行跳动。当顺序跳动之后,就会产生新的鱼。
}
private
lastCount
:
number
;
private
viewFishs
:
Option
[];
private
touchFishs
:
Option
[];
getFishByCount
(
count
)
{
if
(
count
<=
this
.
lastCount
)
return
null
;
if
(
!
this
.
list
)
return
;
if
(
this
.
list
.
length
==
this
.
touchFishs
.
length
)
{
Game
.
getIns
().
state
=
GAME_STATE
.
OVER
;
return
pg
.
event
.
emit
(
"
game_time_over
"
);
}
this
.
lastCount
=
count
;
let
list
=
this
.
list
.
filter
((
li
)
=>
{
return
this
.
viewFishs
.
every
(
v
=>
v
.
id
!=
li
.
id
)
&&
this
.
touchFishs
.
every
(
t
=>
t
.
id
!=
li
.
id
);
});
if
(
list
.
length
==
0
)
return
null
;
let
data
=
JSON
.
parse
(
JSON
.
stringify
(
list
[
count
%
list
.
length
]));
data
.
fish
.
isLeft
=
Math
.
random
()
<
0.5
;
let
item_base
=
data
.
fish
.
isLeft
?
this
.
item_left
:
this
.
item_right
;
let
item
=
cc
.
instantiate
(
item_base
);
this
.
updateFish
(
item
,
data
);
this
.
viewFishs
.
push
(
data
);
return
item
;
}
private
fishCount
:
number
;
private
lastY
:
number
;
updateFish
(
item
,
data
:
Option
)
{
pg
.
view
.
touchOn
(
item
,
this
.
onTouchItem
,
this
);
if
(
!
this
.
fishCount
)
this
.
fishCount
=
0
;
let
id
=
this
.
fishCount
%
5
+
1
;
this
.
fishCount
++
;
let
res
=
pg
.
view
.
find
(
item
,
'
res
'
);
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
img_normal
'
),
true
);
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
img_fall
'
),
false
);
pg
.
view
.
visible
(
pg
.
view
.
find
(
item
,
'
light
'
),
false
);
//
pg
.
view
.
setNodeImg
(
pg
.
view
.
find
(
item
,
'
img_normal
'
),
pg
.
view
.
find
(
res
,
'
img_balloon1_1
'
));
pg
.
view
.
setNodeImg
(
pg
.
view
.
find
(
item
,
'
img_fall
'
),
pg
.
view
.
find
(
res
,
'
img_balloon1_2
'
));
item
.
parent
=
this
.
layout_balloon
;
item
.
data
=
data
;
data
.
fish
.
node
=
item
;
//渲染部分
// if (data.type == "txt") {
// pg.view.visible(pg.view.find(item, 'layout_text'), true);
// pg.view.visible(pg.view.find(item, 'layout_img'), false);
// pg.view.setString(pg.view.find(item, "layout_text/text"), data.txt);
// } else {
// pg.view.visible(pg.view.find(item, 'layout_text'), false);
// pg.view.visible(pg.view.find(item, 'layout_img'), true);
// pg.view.setNetImg(pg.view.find(item, 'layout_img/img'), data.picUrl, { w: 118, h: 110 })
// }
//x y 起始点 和终点 进行 随机
cc
.
Tween
.
stopAllByTarget
(
item
);
//左往右
item
.
x
=
-
1334
/
2
+
Math
.
random
()
*
1334
;
item
.
y
=
-
(
720
/
2
+
Math
.
random
()
*
400
);
//
cc
.
tween
(
item
).
to
(
10
+
Math
.
random
()
*
10
,
{
y
:
1500
}).
call
(()
=>
{
data
.
fish
.
isOut
=
FISH_OUT
.
OUT
;
this
.
viewFishs
=
this
.
viewFishs
.
filter
(
v
=>
v
.
id
!=
data
.
id
);
}).
start
();
}
private
touching
:
boolean
;
fishingRight
(
item
,
layout
,
data
:
Option
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
//弹弓动画。
this
.
item_gun
;
//爆炸效果
//气球下落
// let wave = pg.view.find(layout, 'wave')
// wave.active = true;
// wave.angle = getDegree(cc.v2(item), cc.v2(layout).add(cc.v2(wave)));
// let text = pg.view.find(layout, "text");
// text.active = true;
// data.audioUrl && pg.audio.playAudioByUrl(data.audioUrl)
// cc.tween(item)
// .to(1, { x: layout.x, y: layout.y + wave.y, scaleX: item.scaleX * 0.1, scaleY: item.scaleY * 0.1 }).call(() => {
// //处理内容
// data.fish.isOut = FISH_OUT.OUT;
// wave.active = false;
// text.active = false;
// this.touching = false;
// resolve('');
// }).start();
resolve
(
''
);
});
}
fishingError
(
item
,
layout
,
data
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
pg
.
audio
.
playLocalAudio
(
pg
.
view
.
find
(
this
.
res
,
"
audio/error
"
))
if
(
data
.
fish
.
isLeft
)
{
//左往右
cc
.
tween
(
item
).
to
(
3
,
{
x
:
1500
}).
call
(()
=>
{
data
.
fish
.
isOut
=
FISH_OUT
.
OUT
;
item
.
active
=
false
;
setTimeout
(()
=>
{
item
.
parent
=
null
;
},
1000
);
if
(
this
.
touchFishs
.
every
(
fish
=>
fish
.
id
!=
data
.
id
))
{
resolve
(
''
);
}
}).
start
();
}
else
{
//右往左
cc
.
tween
(
item
).
to
(
3
,
{
x
:
-
1500
}).
call
(()
=>
{
data
.
fish
.
isOut
=
FISH_OUT
.
OUT
;
item
.
active
=
false
;
setTimeout
(()
=>
{
item
.
parent
=
null
;
},
1000
);
if
(
this
.
touchFishs
.
every
(
fish
=>
fish
.
id
!=
data
.
id
))
{
resolve
(
''
);
}
}).
start
();
}
setTimeout
(()
=>
{
this
.
touching
=
false
;
},
500
);
});
}
fishing
(
item
,
layout
)
{
return
new
Promise
(
async
(
resolve
,
reject
)
=>
{
let
data
=
item
.
data
;
//item停止动画并
cc
.
Tween
.
stopAllByTarget
(
item
);
if
(
data
.
right
)
{
await
this
.
fishingRight
(
item
,
layout
,
data
);
}
else
{
await
this
.
fishingError
(
item
,
layout
,
data
);
}
this
.
touchFishs
.
push
(
data
);
return
resolve
(
data
.
right
);
});
}
//开始点击 点击角色
async
onTouchItem
(
e
)
{
if
(
this
.
touching
)
return
;
this
.
touching
=
true
;
let
item
=
e
.
target
;
let
data
=
item
.
data
;
if
(
this
.
touchFishs
.
some
(
fish
=>
fish
.
id
==
data
.
id
))
return
;
if
(
data
.
fish
.
isOut
!=
FISH_OUT
.
RUNNING
)
return
;
data
.
fish
.
isOut
=
FISH_OUT
.
TOUCH
;
let
isRight
=
await
this
.
fishing
(
item
,
this
.
layout_player
);
isRight
&&
Game
.
getIns
().
player
.
addScore
();
!
isRight
&&
Game
.
getIns
().
player
.
addError
();
}
//机器人随机钓鱼
get
fishLen
()
{
if
(
!
this
.
fishs
)
return
999
;
let
arr
=
this
.
fishs
.
filter
(
item
=>
{
let
data
:
Option
=
item
.
data
;
return
data
.
fish
.
isOut
==
FISH_OUT
.
RUNNING
;
})
this
.
fishs
=
arr
;
return
this
.
fishs
.
length
;
}
update
(
dt
)
{
if
(
Game
.
getIns
().
state
!=
GAME_STATE
.
RUNNING
)
return
;
if
(
this
.
fishLen
<
5
)
this
.
count
++
;
let
fish
=
this
.
getFishByCount
(
this
.
count
);
if
(
fish
)
this
.
fishs
.
push
(
fish
);
}
playLocalAudio
(
audioName
)
{
const
audio
=
cc
.
find
(
`Canvas/res/audio/
${
audioName
}
`
).
getComponent
(
cc
.
AudioSource
);
...
...
assets/cocos_generator/scene/tool/pg.ts
View file @
354b163b
...
...
@@ -273,6 +273,18 @@ let pg = {
})
})
},
setNodeImg
(
item
,
target
)
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
!
item
)
return
pg
.
logger
.
w
(
"
图片更换失败,传入了错误的item
"
);
let
spriteFrame
=
target
.
getComponent
(
cc
.
Sprite
).
spriteFrame
;
let
node
=
item
.
node
?
item
.
node
:
item
;
if
(
!
cc
.
isValid
(
node
))
return
pg
.
logger
.
i
(
"
节点已销毁
"
);
let
component
=
node
.
getComponent
(
cc
.
Sprite
);
let
{
width
,
height
}
=
spriteFrame
.
getRect
();
component
.
spriteFrame
=
spriteFrame
;
resolve
({
width
,
height
});
})
},
switchMaterial
(
item
,
id0
=
0
,
id1
=
1
)
{
let
material0
=
item
.
getMaterial
(
id0
);
let
material1
=
item
.
getMaterial
(
id1
);
...
...
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