Keyframe.Keyframe 构造关键帧
static function Keyframe (time : float, value : float) : Keyframe
Description描述
Create a keyframe.
创建一个关键帧。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
private AnimationCurve anim;
private Keyframe[] ks;
void Start() {
ks = new Keyframe[50];
int i = 0;
while (i < ks.Length) {
ks[i] = new Keyframe(i, Mathf.Sin(i));
i++;
}
anim = new AnimationCurve(ks);
}
void Update() {
transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0);
}
}
// Make a GameObject follow a Sinus function
// Over the X and Y axis.
//创建一个游戏物体跟随一个正弦函数,在x和y轴上
private var anim : AnimationCurve;
private var ks : Keyframe[];
function Start() {
ks = new Keyframe[50];
for(var i = 0; i < ks.Length ; i++)
ks[i] = Keyframe(i,Mathf.Sin(i));
anim = AnimationCurve(ks);
}
function Update() {
transform.position = Vector3(Time.time,anim.Evaluate(Time.time),0);
}
•static function Keyframe (time : float, value : float, inTangent : float, outTangent : float) : Keyframe
Description描述
Create a keyframe.
创建一个关键帧。
using UnityEngine;
using System.Collections;
public class example : MonoBehaviour {
private AnimationCurve anim;
private Keyframe[] ks;
void Start() {
ks = new Keyframe[50];
int i = 0;
while (i < ks.Length) {
ks[i] = new Keyframe(i, Mathf.Sin(i), 90, 90);
i++;
}
anim = new AnimationCurve(ks);
}
void Update() {
transform.position = new Vector3(Time.time, anim.Evaluate(Time.time), 0);
}
}
// Make a GameObject follow a Sinus function
// Over the X and Y axis with vertical tangents.
//创建一个游戏物体跟随一个正弦函数,使用垂直切线在x和y轴上
private var anim : AnimationCurve;
private var ks : Keyframe[];
function Start() {
ks = new Keyframe[50];
for(var i = 0; i < ks.Length ; i++){
ks[i] = Keyframe(i,Mathf.Sin(i),90,90);
}
anim = AnimationCurve(ks);
}
function Update() {
transform.position = Vector3(Time.time,anim.Evaluate(Time.time),0);
}
最后修改:2011年2月24日 Thursday 15:39