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
65923b2f
Commit
65923b2f
authored
Mar 10, 2021
by
邱旭
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
02.会飞的鸟
parent
8d4c067b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
100 additions
and
0 deletions
+100
-0
02.会飞的鸟.html
02.会飞的鸟/02.会飞的鸟.html
+59
-0
02.会飞的鸟.md
02.会飞的鸟/02.会飞的鸟.md
+41
-0
No files found.
02.会飞的鸟/02.会飞的鸟.html
0 → 100644
View file @
65923b2f
<!DOCTYPE html>
<html
lang=
"zh"
>
<head>
<meta
charset=
"UTF-8"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"
/>
<title>
02.会飞的鸟
</title>
<style>
html
,
body
{
margin
:
0
;
padding
:
0
;
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
}
#bird
{
/* 大小 */
width
:
50px
;
height
:
50px
;
/* 颜色 */
background-color
:
#f00
;
/* 位置 */
position
:
absolute
;
top
:
50%
;
left
:
50%
;
/* 旋转、缩放等属性 */
transform
:
scale
(
1
,
1
)
rotate
(
45deg
);
/* 锚点 */
transform-origin
:
center
;
/* 动画 */
animation
:
bird-fly
5s
infinite
;
}
@keyframes
bird-fly
{
0
%
{
top
:
50%
;
transform
:
scale
(
1
,
1
)
rotate
(
45deg
)
}
50
%
{
top
:
30%
;
transform
:
scale
(
1
,
1
)
rotate
(
45deg
)
}
100
%
{
top
:
50%
;
transform
:
scale
(
1
,
1
)
rotate
(
45deg
)
}
}
</style>
</head>
<body>
<div
id=
"bird"
></div>
</body>
</html>
02.会飞的鸟/02.会飞的鸟.md
0 → 100644
View file @
65923b2f
# 会飞的Bird
引入概念:使用
`动画`
改变显示对象属性
动画是一个游戏重要的组成部分,如果没有动画,游戏将变得枯燥无味
本小节创建一个简单keyframe动画,以此来理解游戏中的动画
在style标签中加入一段动画的代码
```
css
@keyframes
bird-fly
{
0
%
{
top
:
50%
;
transform
:
scale
(
1
,
1
)
rotate
(
45deg
)
}
50
%
{
top
:
30%
;
transform
:
scale
(
1
,
1
)
rotate
(
45deg
)
}
100
%
{
top
:
50%
;
transform
:
scale
(
1
,
1
)
rotate
(
45deg
)
}
}
```
把刚刚我们写的css动画应用在我们的Bird上
```
css
#bird
{
[...]
/* 动画 */
animation
:
bird-fly
5s
infinite
;
}
```
经过一顿操作,我们得到了自己一只活生生的鸟
但是这样的方式似乎无法自由的操作
想想王者荣耀,你的英雄该如何送塔?
如下图:
![
02_1.gif
](
../images/02_1.gif
)
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