纳金网

标题: iTween学习笔记之抛物线代码 [打印本页]

作者: 刀锋狼    时间: 2014-4-30 02:47
标题: iTween学习笔记之抛物线代码
  1. using UnityEngine;
  2. using System.Collections;

  3. public class CourseiTweenLine : MonoBehaviour {
  4.     public GameObject target;
  5.     public GameObject ballPrefab;

  6.     private Vector3[] paths=new Vector3[3];
  7.     // Use this for initialization
  8.     void Start () {
  9.      
  10.     }
  11.      
  12.     // Update is called once per frame
  13.     void Update () {
  14.         Ray ray = camera.ScreenPointToRay(Input.mousePosition);
  15.         RaycastHit hit;
  16.         if (Physics.Raycast(ray, out hit))
  17.         {
  18.             if (hit.transform.gameObject.tag == "tile")
  19.             {
  20.                 iTween.MoveUpdate(target, new Vector3(hit.point.x, 0.1f, hit.point.z), 0.1f);

  21.                 if (Input.GetMouseButtonDown(0))
  22.                 {
  23.                     GameObject go = (GameObject)Instantiate(ballPrefab, new Vector3(0, 0, 0), Quaternion.identity);
  24.                     paths[0] = new Vector3(0, 0, 0);
  25.                     paths[2] = hit.point;
  26.                     paths[1] = new Vector3(hit.point.x / 2, 3f, hit.point.z / 2);
  27.                     //这几个参数要记
  28.                     iTween.MoveTo(go, iTween.Hash("path", paths, "movetopath", true, "orienttopath", true, "time", 1, "easetype", iTween.EaseType.linear));
  29.                     Destroy(go, 1.8f);
  30.                 }
  31.             }
  32.         }
  33.     }
  34.     private void OnDrawGizmos()
  35.     {
  36.         iTween.DrawLine(paths, Color.blue);
  37.         iTween.DrawPath(paths, Color.red);
  38.     }
  39. }
复制代码

作者: hyui    时间: 2014-4-30 03:49
time to learn fro others code)))




欢迎光临 纳金网 (http://course.narkii.com/club/) Powered by Discuz! X2.5