Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
hello_canvas
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
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
wildfirecode13
hello_canvas
Commits
b188f161
Commit
b188f161
authored
Sep 01, 2020
by
wildfirecode13
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1
parent
340d4506
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
53 additions
and
14 deletions
+53
-14
DropItem.ts
project/src/canvas/game/src/scenes/DropItem.ts
+4
-12
DropsCtrl.ts
project/src/canvas/game/src/scenes/DropsCtrl.ts
+45
-0
Root.ts
project/src/canvas/game/src/scenes/Root.ts
+4
-2
No files found.
project/src/canvas/game/src/scenes/DropItem.ts
View file @
b188f161
import
resCanvasList
from
"../../resCanvasList"
;
import
{
RES
}
from
"../../module/RES"
;
import
{
getStage
}
from
"./stage
"
;
import
resCanvasList
from
"../../resCanvasList
"
;
export
default
class
DropItem
extends
FYGE
.
Sprite
{
constructor
()
{
super
();
...
...
@@ -8,17 +7,10 @@ export default class DropItem extends FYGE.Sprite {
this
.
texture
=
RES
.
getRes
(
resCanvasList
[
"593e9d74-4944-496a-b6c1-8316756f8bf7"
].
url
);
getStage
().
addEventListener
(
FYGE
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
this
.
y
=
0
;
this
.
y
=
0
;
}
onEnterFrame
()
{
this
.
y
+=
10
;
updatePosition
()
{
this
.
y
+=
10
;
}
}
project/src/canvas/game/src/scenes/DropsCtrl.ts
0 → 100644
View file @
b188f161
import
Root
from
"./Root"
;
import
{
getStage
}
from
"./stage"
;
import
DropItem
from
"./DropItem"
;
export
default
class
DropsCtrl
{
_root
:
Root
;
_drops
:
DropItem
[];
constructor
(
root
)
{
this
.
_root
=
root
;
}
start
()
{
getStage
().
addEventListener
(
FYGE
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
for
(
let
index
=
0
;
index
<
10
;
index
++
)
{
setTimeout
(()
=>
{
this
.
addDropItem
();
},
1000
*
index
);
}
}
addDropItem
()
{
this
.
_drops
=
this
.
_drops
||
[];
const
drop
=
new
DropItem
();
this
.
_root
.
addChild
(
drop
);
drop
.
x
=
Math
.
random
()
*
400
+
(
750
-
400
)
/
2
;
this
.
_drops
.
push
(
drop
);
}
onEnterFrame
()
{
if
(
this
.
_drops
)
this
.
_drops
.
forEach
((
drop
)
=>
drop
.
updatePosition
());
}
destroy
()
{
getStage
().
removeEventListener
(
FYGE
.
Event
.
ENTER_FRAME
,
this
.
onEnterFrame
,
this
);
}
}
project/src/canvas/game/src/scenes/Root.ts
View file @
b188f161
import
{
RES
}
from
"../../module/RES"
;
import
resCanvasList
from
"../../resCanvasList"
;
import
DropItem
from
"./DropItem"
;
import
DropsCtrl
from
"./DropsCtrl"
;
export
default
class
Root
extends
FYGE
.
Container
{
constructor
()
{
super
();
...
...
@@ -14,7 +15,8 @@ export default class Root extends FYGE.Container {
);
this
.
addChild
(
bg
);
this
.
addChild
(
new
DropItem
())
const
ctrl
=
new
DropsCtrl
(
this
);
ctrl
.
start
();
// SvgaParser.loadSvga(
// "//yun.duiba.com.cn/spark/assets/open_effect.b997f18f52ca96abb0913ca32fdce6f22ad9bcf7.svga",
...
...
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