码迷,mamicode.com
首页 > 其他好文 > 详细

fly bird 案例代码_bird

时间:2015-11-08 19:14:25      阅读:159      评论:0      收藏:0      [点我收藏+]

标签:

 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class bird : MonoBehaviour {
 5     public float timer = 0;
 6     public int freamNumbuer = 10;
 7     public int freamCount=0;
 8 
 9     void Update() {
10         //小鸟动画
11         if (GameMangger._intance.GameState == GameMangger.GAMESTATE_RUNING)
12         {
13             {
14                 timer += Time.deltaTime;
15                 if (timer >= 1.0f / freamNumbuer)
16                 {
17                     freamCount++;
18                     timer -= 1.0f / freamNumbuer;
19                     int freamIndex = freamCount % 3;
20                     this.renderer.material.SetTextureOffset("_MainTex", new Vector2(0.3333f * freamIndex, 0));
21                 }
22             }
23         }
24 
25         //按鼠标左键实现小鸟跳动画
26         if (GameMangger._intance.GameState == GameMangger.GAMESTATE_RUNING)
27         {
28             {
29                 if (Input.GetMouseButtonDown(0))
30                 {
31                     audio.Play();
32                     Vector3 vel02 = this.rigidbody.velocity;
33                     this.rigidbody.velocity = new Vector3(vel02.x, 3, vel02.z);
34                 }
35             }
36         }
37     }
38     //小鸟得到生命
39     public void getLife()
40     {
41         rigidbody.useGravity = true;
42         rigidbody.velocity = new Vector3(3, 0, 0);
43     }
44 }

 

fly bird 案例代码_bird

标签:

原文地址:http://www.cnblogs.com/wry524/p/4947824.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!