FlappyBird视频代码Word文档下载推荐.docx
- 文档编号:18791679
- 上传时间:2023-01-01
- 格式:DOCX
- 页数:8
- 大小:16.69KB
FlappyBird视频代码Word文档下载推荐.docx
《FlappyBird视频代码Word文档下载推荐.docx》由会员分享,可在线阅读,更多相关《FlappyBird视频代码Word文档下载推荐.docx(8页珍藏版)》请在冰豆网上搜索。
,"
Button2"
Button3"
};
foreach
(string
name
in
btnnames)
GameObject
obj
GameObject.Find
(name);
Button
btn
obj.GetComponent<
Button>
();
btn.onClick.AddListener
(delegate()
this.OnClick(obj);
});
}
OnClick(GameObject
obj){
switch
(obj.name)
case
"
GameManager.Instance.Difficulty
1;
//SceneManager.LoadScene
("
GameScene"
);
break;
2;
3;
default:
2.TextDifficulityScript
TextDifficulityScript
string
difficultyID
GameManager.Instance.DifficultyID;
TextDifficulty"
).GetComponent<
Text>
().text=difficultyID;
Update
is
called
once
per
frame
3.GameManager
GameManager
private
static
instance=null;
GameManager(){
Instance
get
{
if
(instance
==
null)
instance
new
return
instance;
}
//************************************************
int
score=0;
Score{
get{
score;
set{
score
value;
ScroeUp(){
++score;
//----------------不同难度----------------
float
pipeMoveSpeed=0.0f;
restartInterval=0.0f;
radomForY=0.0f;
;
Difficulty{
(value)
1:
pipeMoveSpeed
0.2f;
restartInterval
4.0f;
radomForY
0.0f;
菜鸟级"
2:
0.4f;
2.0f;
普通级"
3:
=1f;
1.0f;
0.5f;
专家级"
SceneManager.LoadScene
DifficultyID{
difficultyID;
RestartInterval{
restartInterval;
}}
RadomForY{
radomForY;
PipeMoveSpeed{
pipeMoveSpeed;
UpdateScore(){
record
PlayerPrefs.GetInt
record"
(this.score
>
record)
PlayerPrefs.SetInt
this.score);
GetRecord(){
record;
4.PipeScript
PipeScript
bool
isUpdating
false;
this.GoBackWait
(!
this.isUpdating)
return;
speed
GameManager.Instance.PipeMoveSpeed;
x
-speed*Time.deltaTime;
gameObject.transform.position
+=
Vector3
(x,
0.0f,
0.0f);
(gameObject.transform.position.x
<
-4.5f)
GoBackWait(){
range
GameManager.Instance.RadomForY;
y
Random.Range(-range,
range);
Vector3(4.5f,y,0.0f);
restart(){
true;
IsUpdating{//访问器,在GameSceneManager.cs中会获取isUpdating的值
get{
isUpdating;
5.FloorScript
FloorScript
-speed*
Time.deltaTime;
-10)
(10.0f,
6.BirdScript
BirdScript
Rigidbody2D
rigid2D=null;
AudioSource
flysound
null;
hitsound
this.rigid2D
gameObject.GetComponent<
Rigidbody2D>
//this.flysound
AudioSource>
(Input.GetMouseButtonDown
(0))
this.rigid2D.velocity
=new
Vector2(0.0f,
5.0f);
this.flysound.Play
OnCollisionEnter2D(Collision2D
other){
tag
other.collider.tag;
if(tag=="
pipecollider"
||tag=="
floor"
){
this.hitsound.Play
this.die
die(){
GameOverScene"
}
7.GameSceneScript
GameSceneScript
GameObject[]
pipes=null;
this.pipes
GameObject.FindGameObjectsWithTag
pipe"
StartCoroutine
IntervalCallee"
StartOnePipe(){
(int
i
0;
pipes.Length;
i++)
pipe=this.pipes
[i].GetComponent<
PipeScript>
pipe.IsUpdating)
pipe.restart
IEnumerator
IntervalCallee(){//counter
interval
GameManager.Instance.RestartInterval;
yield
WaitForSeconds
(interval);
this.StartOnePipe
8.ScroeTriggerScript
ScroeTriggerScript
Text
TextScore=null;
scoresound
this.TextScore
TextScore"
).GetComponent
this.scoresound
OnTriggerExit2D(Collider2D
(other.name
bird"
)
GameManager.Instance.ScroeUp
().ToString
this.TextScore.text
Score:
+
this.scoresound.Play();
9.GameOverScene
GameOverScene
time
TextThisTime"
time.text
本次成绩:
+GameManager.Instance.Score.ToString();
TextRecord"
record.text
记录:
GameManager.Instance.GetRecord().ToString();
GameManager.Instance.UpdateScore
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- FlappyBird 视频 代码
![提示](https://static.bdocx.com/images/bang_tan.gif)