码迷,mamicode.com
首页 > 移动开发 > 详细

iTween的使用:小球抛物线移动

时间:2016-02-01 18:14:46      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:

 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class course3 : MonoBehaviour {
 5 
 6 
 7     public GameObject target;
 8     public GameObject ballprefab;
 9     public Vector3[] paths;
10     // Use this for initialization
11     void Start () {
12         iTween.ColorTo(this.gameObject,Color.black,0);
13     }
14     
15     // Update is called once per frame
16     void Update () {
17 
18         Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
19         RaycastHit hit;
20         if (Physics.Raycast(ray,out hit))
21         {
22             if (hit.transform.gameObject.tag == "tile")
23             {
24                 iTween.MoveUpdate(target,new Vector3(hit.point.x,0.2f,hit.point.z),0.1f);
25             }
26             if (Input.GetMouseButtonDown(0))
27             {
28                 GameObject obj = (GameObject)Instantiate(ballprefab,Vector3.zero,Quaternion.identity);
29                 paths[0] = new Vector3(0, 0, 0);
30                 paths[2] = hit.point;
31                 paths[1] = new Vector3(paths[2].x/2, 3f, paths[2].z/2);
32                 iTween.MoveTo(obj,iTween.Hash("path",paths,"movetopath",true,"orienttopath",true,"time",1,"easetype",iTween.EaseType.linear));
33                 //movetopath 按路径移动,orienttopath 在初始处移动
34                 Destroy(obj, 3);
35             }
36         }
37     }
38 
39     void OnDrawGizmos()
40     {
41         iTween.DrawLine(paths, Color.blue);
42         iTween.DrawPath(paths, Color.red);
43     }
44 
45 
46 }

 

iTween的使用:小球抛物线移动

标签:

原文地址:http://www.cnblogs.com/GGman/p/5175556.html

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