zl程序教程

您现在的位置是:首页 >  其它

当前栏目

u3d

2023-09-27 14:27:29 时间


//sport.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using  UnityEngine.UI;


public class sport : MonoBehaviour {
//定义精灵
public Sprite onebird;
public Sprite twobird;
private Image bird;
private int i = 0;


void Start () {

bird = GetComponent<Image> ();
InvokeRepeating ("ChangePic",0.1F,0.1F);//方法体,间隔多长时间后开始调用函数,调用函数的频率


}

private  void  ChangePic()//根据次数定义小鸟翅膀挥动
{
++i;
if(i%2==0)
{
bird.sprite = twobird;
}
else
{
bird.sprite = onebird;
}


}




void Update () {
if(Input.GetMouseButtonDown(0)==true)//捕捉到鼠标下点
{
print ("鼠标果然按下了,呵呵!!!");
Rigidbody2D body = GetComponent<Rigidbody2D> ();//刚体
body.velocity = new Vector2 (0,200);


  }


}

}





//sky01.cs


using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class sky01 : MonoBehaviour {


void Start () {

}


void Update () {
gameObject.transform.Translate (-2,0,0);
}
}





//zhuan.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


public class zhuan : MonoBehaviour {


// Use this for initialization
void Start () {

}

// Update is called once per frame
void Update () {
gameObject.transform.Rotate (0,10,0);
}
}