Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
game-stydy
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
谌继荃
game-stydy
Commits
c962604a
Commit
c962604a
authored
Mar 10, 2021
by
邱旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
09.FlppyBird-节点树
parent
7a22a4dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
6 additions
and
25 deletions
+6
-25
09.FlppyBird-节点树.html
09.FlppyBird-节点树/09.FlppyBird-节点树.html
+1
-6
09.FlppyBird-节点树.md
09.FlppyBird-节点树/09.FlppyBird-节点树.md
+5
-19
No files found.
09.FlppyBird-节点树/09.FlppyBird-节点树.html
View file @
c962604a
...
...
@@ -81,14 +81,9 @@
this
.
bg1
=
bg1
;
this
.
bg2
=
bg2
;
this
.
speed
=
speed
;
}
async
start
()
{
super
.
start
();
this
.
addChild
(
this
.
bg1
);
this
.
addChild
(
this
.
bg2
);
}
ready
()
{
...
...
@@ -140,7 +135,7 @@
return
Promise
.
all
(
promises
);
}
async
start
()
{
async
ready
()
{
// 创建鸟
const
bird
=
this
.
bird
=
new
Bird
();
...
...
09.FlppyBird-节点树/09.FlppyBird-节点树.md
View file @
c962604a
...
...
@@ -37,12 +37,6 @@ class GameObject {
this
.
dom
.
style
.
position
=
"absolute"
;
}
/**
* 生命周期 start 所有构造函数完成,执行此函数
*/
async
start
()
{
}
/**
* 生命周期 start 加入显示列表执行此函数
*/
...
...
@@ -66,11 +60,8 @@ class GameObject {
child
.
parent
=
this
;
// 容错:防止子类重写的start不是async函数
// TODO dom无法在节点不在渲染树的上的时候拿到clientWidth等属性,故将start和ready放在这里
(
async
()
=>
{
await
child
.
start
();
child
.
ready
();
})();
// TODO dom无法在节点不在渲染树的上的时候拿到clientWidth等属性,故将ready放在这里
child
.
ready
();
return
child
;
}
...
...
@@ -163,7 +154,7 @@ class GameStage extends GameObject {
async
_gameStart
()
{
await
this
.
reloadRes
();
this
.
start
();
this
.
ready
();
}
/**
...
...
@@ -227,14 +218,9 @@ class Bird extends Sprite {
this
.
bg1
=
bg1
;
this
.
bg2
=
bg2
;
this
.
speed
=
speed
;
}
async
start
()
{
super
.
start
();
this
.
addChild
(
this
.
bg1
);
this
.
addChild
(
this
.
bg2
);
}
ready
()
{
...
...
@@ -298,7 +284,7 @@ class FlppyBird extends GameStage {
return
Promise
.
all
(
promises
);
}
async
start
()
{
async
ready
()
{
// 创建鸟
const
bird
=
this
.
bird
=
new
Bird
();
...
...
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