Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
unit_demo
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
unit_demo
Commits
4c35d946
Commit
4c35d946
authored
Sep 17, 2020
by
范雪寒
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 烟花效果
parent
8e467e99
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
712 additions
and
42 deletions
+712
-42
demo_01_showFireworks.fire
play/assets/tmpGame/scene/demo_01_showFireworks.fire
+645
-1
demo_01_showFireworks.js
play/assets/tmpGame/scene/demo_01_showFireworks.js
+23
-16
utils.js
play/assets/tmpGame/script/utils.js
+44
-25
No files found.
play/assets/tmpGame/scene/demo_01_showFireworks.fire
View file @
4c35d946
This diff is collapsed.
Click to expand it.
play/assets/tmpGame/scene/demo_01_showFireworks.js
View file @
4c35d946
...
@@ -4,34 +4,41 @@
...
@@ -4,34 +4,41 @@
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
// Learn life-cycle callbacks:
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
// - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html
import
{
showFireworks
,
}
from
'
../script/utils
'
;
cc
.
Class
({
cc
.
Class
({
extends
:
cc
.
Component
,
extends
:
cc
.
Component
,
properties
:
{
properties
:
{
// foo: {
// // ATTRIBUTES:
// default: null, // The default value will be used only when the component attaching
// // to a node for the first time
// type: cc.SpriteFrame, // optional, default is typeof default
// serializable: true, // optional, default is true
// },
// bar: {
// get () {
// return this._bar;
// },
// set (value) {
// this._bar = value;
// }
// },
},
},
// LIFE-CYCLE CALLBACKS:
// LIFE-CYCLE CALLBACKS:
// onLoad () {},
// onLoad () {},
start
()
{
start
()
{
const
BtnFire
=
cc
.
find
(
'
Canvas/BtnFire
'
);
BtnFire
.
on
(
'
click
'
,
()
=>
{
showFireworks
(
cc
.
find
(
'
Canvas/Main Camera
'
),
cc
.
find
(
'
RibbonNodeBase
'
).
children
,
cc
.
v2
(
0
,
-
400
),
cc
.
v2
(
0
,
1000
),
200
,
200
);
showFireworks
(
cc
.
find
(
'
Canvas/Main Camera
'
),
cc
.
find
(
'
RibbonNodeBase
'
).
children
,
cc
.
v2
(
-
600
,
-
400
),
cc
.
v2
(
200
,
1000
),
200
,
200
);
showFireworks
(
cc
.
find
(
'
Canvas/Main Camera
'
),
cc
.
find
(
'
RibbonNodeBase
'
).
children
,
cc
.
v2
(
600
,
-
400
),
cc
.
v2
(
-
200
,
1000
),
200
,
200
);
});
},
},
// update (dt) {},
// update (dt) {},
...
...
play/assets/tmpGame/script/utils.js
View file @
4c35d946
...
@@ -134,43 +134,62 @@ export async function asyncDelay(time) {
...
@@ -134,43 +134,62 @@ export async function asyncDelay(time) {
}
}
export
async
function
showFireworks
(
baseNode
,
nodeList
,
pos
=
cc
.
v2
(
0
,
0
),
side
=
cc
.
v2
(
0
,
100
),
range
=
50
,
number
=
100
)
{
export
async
function
showFireworks
(
baseNode
,
nodeList
,
pos
=
cc
.
v2
(
0
,
0
),
side
=
cc
.
v2
(
0
,
100
),
range
=
50
,
number
=
100
)
{
for
(
let
i
=
0
;
i
<
number
;
i
++
)
{
new
Array
(
number
).
fill
(
'
'
).
forEach
(
async
(
_
,
i
)
=>
{
const
node
=
cc
.
instantiate
(
nodeList
[
RandomInt
(
nodeList
.
length
)]);
node
.
parent
=
baseNode
;
let
rabbonNode
=
new
cc
.
Node
();
rabbonNode
.
parent
=
baseNode
;
rabbonNode
.
x
=
pos
.
x
;
rabbonNode
.
y
=
pos
.
y
;
rabbonNode
.
angle
=
60
*
Math
.
random
()
-
30
;
let
node
=
cc
.
instantiate
(
nodeList
[
RandomInt
(
nodeList
.
length
)]);
node
.
parent
=
rabbonNode
;
node
.
active
=
true
;
node
.
active
=
true
;
node
.
x
=
pos
.
x
;
node
.
x
=
0
;
node
.
y
=
pos
.
y
;
node
.
y
=
0
;
node
.
angle
=
360
*
Math
.
random
();
node
.
angle
=
0
;
node
.
scale
=
0.5
;
const
rate
=
Math
.
random
();
const
rate
=
Math
.
random
();
const
angle
=
Math
.
PI
*
(
Math
.
random
()
*
2
-
1
);
const
angle
=
Math
.
PI
*
(
Math
.
random
()
*
2
-
1
);
await
asyncTweenBy
(
rabbonNode
,
0.3
,
{
x
:
side
.
x
*
rate
+
Math
.
cos
(
angle
)
*
range
*
rate
,
y
:
side
.
y
*
rate
+
Math
.
sin
(
angle
)
*
range
*
rate
},
{
easing
:
'
quadIn
'
});
cc
.
tween
(
rabbonNode
)
.
by
(
8
,
{
y
:
-
2000
})
.
start
();
rabbonFall
(
rabbonNode
);
await
asyncDelay
(
Math
.
random
());
cc
.
tween
(
node
)
cc
.
tween
(
node
)
.
by
(
0.3
,
{
.
by
(
0.15
,
{
x
:
-
10
,
angle
:
-
10
})
x
:
side
.
x
*
rate
+
Math
.
cos
(
angle
)
*
range
*
rate
,
.
by
(
0.3
,
{
x
:
20
,
angle
:
20
})
y
:
side
.
y
*
rate
+
Math
.
sin
(
angle
)
*
range
*
rate
.
by
(
0.15
,
{
x
:
-
10
,
angle
:
-
10
})
})
.
union
()
.
call
(
async
()
=>
{
.
repeatForever
()
for
(
let
i
=
0
;
i
<
8
;
i
++
)
{
.
start
();
await
rabbonFall
(
node
);
}
cc
.
tween
(
rabbonNode
)
cc
.
tween
(
node
)
.
delay
(
5
)
.
to
(
0.3
,
{
opacity
:
0
})
.
to
(
0.3
,
{
opacity
:
0
})
.
call
(()
=>
{
.
call
(()
=>
{
node
.
active
=
false
;
node
.
stopAllActions
();
node
.
parent
=
null
;
node
.
active
=
false
;
node
=
null
;
node
.
parent
=
null
;
})
node
=
null
;
.
start
();
})
})
.
by
(
8
,
{
y
:
-
2000
})
.
start
();
.
start
();
}
}
);
}
}
async
function
rabbonFall
(
node
)
{
async
function
rabbonFall
(
node
)
{
const
time
=
1
+
Math
.
random
();
const
time
=
1
+
Math
.
random
();
const
offsetX
=
RandomInt
(
-
200
,
200
)
*
time
;
const
offsetX
=
RandomInt
(
-
200
,
200
)
*
time
;
await
asyncTweenBy
(
node
,
time
,
{
x
:
offsetX
,
angle
:
offsetX
*
60
/
200
});
await
asyncTweenBy
(
node
,
time
,
{
x
:
offsetX
,
angle
:
offsetX
*
60
/
200
});
rabbonFall
(
node
);
}
}
\ 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