Unity5.X3D制作java飞机大战制作的难点有什么

unity学习之飞机大战制作 关键点(四) 设置敌机和奖励物品的生成和随机
特别说明,因为敌机和奖励物品的代码方式差不多,我就放在一个代码里面写了。
3.1添加敌机以及敌机的移动
依旧是把图片拉到Hierarchy里面生成对象,添加代码,然后拖回scenes文件夹,就可以制作成prefab。
关键点:添加了hp,奖励物品的hp可以设置为0,score和speed也是如此,根据自己的要求改变。
score:分数
speed:速度
3.2 随机生成敌机
说明 : enemy1Prefab:敌机1
Reward1:奖励物品1
Reward1Rate:敌机生成间隔时间
别看代码多,其实很简单,先写出生成随机生成一台敌机的方法,即public void careteEnemy0()
再添加Random关键字,使得生成敌机的时候X轴随机,注意生成的时候不要超出game屏幕,具体自己量。
Instantiate方法用来实例化对象。
最后再在start里面InvokeRepeating方法可以每隔多少秒调用生成敌机的方法。
关键点:instantiate(游戏对象,坐标轴,四元数)
游戏对象:public gameObject
坐标轴:三维,vector3
四元数:简单点就是问你是否旋转。
没有更多推荐了,
加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!&>&Unity3D 之2d开发,飞机大战所有源代码
Unity3D 之2d开发,飞机大战所有源代码
上传大小:5.21MB
适合Unity初学者。实现了基本角色的创建、角色的移动等常用操作,是入门的比用案例。
综合评分:5
{%username%}回复{%com_username%}{%time%}\
/*点击出现回复框*/
$(".respond_btn").on("click", function (e) {
$(this).parents(".rightLi").children(".respond_box").show();
e.stopPropagation();
$(".cancel_res").on("click", function (e) {
$(this).parents(".res_b").siblings(".res_area").val("");
$(this).parents(".respond_box").hide();
e.stopPropagation();
/*删除评论*/
$(".del_comment_c").on("click", function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_invalid/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parents(".conLi").remove();
alert(data.msg);
$(".res_btn").click(function (e) {
var parentWrap = $(this).parents(".respond_box"),
q = parentWrap.find(".form1").serializeArray(),
resStr = $.trim(parentWrap.find(".res_area_r").val());
console.log(q);
//var res_area_r = $.trim($(".res_area_r").val());
if (resStr == '') {
$(".res_text").css({color: "red"});
$.post("/index.php/comment/do_comment_reply/", q,
function (data) {
if (data.succ == 1) {
var $target,
evt = e || window.
$target = $(evt.target || evt.srcElement);
var $dd = $target.parents('dd');
var $wrapReply = $dd.find('.respond_box');
console.log($wrapReply);
//var mess = $(".res_area_r").val();
var mess = resS
var str = str.replace(/{%header%}/g, data.header)
.replace(/{%href%}/g, 'http://' + window.location.host + '/user/' + data.username)
.replace(/{%username%}/g, data.username)
.replace(/{%com_username%}/g, data.com_username)
.replace(/{%time%}/g, data.time)
.replace(/{%id%}/g, data.id)
.replace(/{%mess%}/g, mess);
$dd.after(str);
$(".respond_box").hide();
$(".res_area_r").val("");
$(".res_area").val("");
$wrapReply.hide();
alert(data.msg);
}, "json");
/*删除回复*/
$(".rightLi").on("click", '.del_comment_r', function (e) {
var id = $(e.target).attr("id");
$.getJSON('/index.php/comment/do_comment_del/' + id,
function (data) {
if (data.succ == 1) {
$(e.target).parent().parent().parent().parent().parent().remove();
$(e.target).parents('.res_list').remove()
alert(data.msg);
//填充回复
function KeyP(v) {
var parentWrap = $(v).parents(".respond_box");
parentWrap.find(".res_area_r").val($.trim(parentWrap.find(".res_area").val()));
评论共有3条
对初学者很有帮助!
很简单的源码,适合初学者
对初学者很有帮助!
综合评分:
积分/C币:5
flying1112
综合评分:
积分/C币:3
VIP会员动态
CSDN下载频道资源及相关规则调整公告V11.10
下载频道用户反馈专区
下载频道积分规则调整V1710.18
spring mvc+mybatis+mysql+maven+bootstrap 整合实现增删查改简单实例.zip
资源所需积分/C币
当前拥有积分
当前拥有C币
输入下载码
为了良好体验,不建议使用迅雷下载
Unity3D 之2d开发,飞机大战所有源代码
会员到期时间:
剩余下载个数:
剩余积分:0
为了良好体验,不建议使用迅雷下载
积分不足!
资源所需积分/C币
当前拥有积分
您可以选择
程序员的必选
绿色安全资源
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
为了良好体验,不建议使用迅雷下载
资源所需积分/C币
当前拥有积分
当前拥有C币
您的积分不足,将扣除 10 C币
为了良好体验,不建议使用迅雷下载
无法举报自己的资源
你当前的下载分为234。
你还不是VIP会员
开通VIP会员权限,免积分下载
你下载资源过于频繁,请输入验证码
您因违反CSDN下载频道规则而被锁定帐户,如有疑问,请联络:!
若举报审核通过,可返还被扣除的积分
被举报人:
举报的资源分:
请选择类型
资源无法下载 ( 404页面、下载失败、资源本身问题)
资源无法使用 (文件损坏、内容缺失、题文不符)
侵犯版权资源 (侵犯公司或个人版权)
虚假资源 (恶意欺诈、刷分资源)
含色情、危害国家安全内容
含广告、木马病毒资源
*详细原因:
Unity3D 之2d开发,飞机大战所有源代码每个组件都是一个类的实例,要获得某个组件,要先创建一个同类型的组件类实例,然后把实例传引用过去,就可以对想要的组件实例进行操作。
做游戏一般创建一个逻辑节点,里面只管逻辑,再创建一个动画节点,里面有好多动画节点。一般我们把逻辑节点作为动画节点的父节点。
开发步骤:
1: 搭建unity项目工程; 2: 资源整理好; 3: 配置好我们的 4: 做一个开始界面;
5: 做一个总的游戏的控制脚本game_ 6: 点击开始按钮,让这个开始界面消失; 7: 让这个飞行射击类游戏背景滚动起来;8: 创建一个飞机,能让它被自由的移动和拖动;
9: 创建一个子弹,能够在物理引擎的控制下发射出去;10:
产生一个预制体,让这个飞机不断的射击;11: 修改开始,让玩家获得开始消息;
步骤一和步骤二&&&&&&搭建unity项目工程&&&&&&资源整理好
1.创建一个2D的Unity项目
2.创建好scenes,resources,scripts文件夹
3.在resources文件夹下再创建一个tex文件夹
4.把要用到的图片资源放进tex文件夹中
5.保存场景到scenes文件夹
步骤三&&&&&&配置好我们的canvas
1.创建一个Canvas节点
2.把Canvas节点的Canvas组件中的Render Mode设置为Screen Space-Camera,并把Main Camera节点拖进Render Camera属性
3.把Canvas节点的Canvas Scaler组件的UI Scale Mode设置为Scale With Screen Size,并把Refernces Resultion设置为和Game视图分辨率一样的640X960
4.创建两个空节点game_root和menu_root作为Canvas节点的子节点,game_root是用来放游戏的节点,menu_root是用来放菜单的节点。由于还没有讲场景跳转,所以这里需要这两个节点。
步骤四&&&&&&做一个开始界面
1.给menu_root创建一个叫menu_bg的Image子节点,把背景拖进去,set native size。
2.给menu_root创建一个叫start_button的button子节点,,把按钮贴纸拖进去,set native size,把它自带的Text子节点删除。
步骤五&&&&&&做一个总的游戏的控制脚本game_scene
1.创建一个叫game_scene的脚本挂载在Canvas下面作为游戏总控制的脚本。
步骤六&&&&&&点击开始按钮,让这个开始界面消失
1.打开game_scene脚本,编写一个游戏开始函数,on_game_start_click(){}
using UnityE
using System.C
public class game_scene : MonoBehaviour {
//设置一个开始游戏的标志
bool is_started = false;
// Use this for initialization
void Start () {
//删除菜单节点函数
  private void delete_menu() {
MonoBehaviour.Destroy(GameObject.Find("Canvas/menu_root"));
//游戏开始按钮点击,菜单按钮点击后的响应函数,记得要设置为public权限才能关联按钮
public void on_game_start_click() {
     //防止重复点击 
if (this.is_started) {
this.is_started = true;
     //执行一个定时器(自带的),让删除节点的函数过一会再执行,过渡效果
this.Invoke("delete_menu", <span style="color: #.2f);
// Update is called once per frame
void Update () {
2.写好按钮事件函数后,可以直接在Inspector视图里面关联相应的按钮,就是在按钮的属性视图的最下面。
步骤七&&&&&&让这个飞行射击类游戏背景滚动起来
1.先把menu_root节点隐藏起来,像ps里面的把眼睛关掉
2. 给game_root创建一个叫sky的Raw Image子节点(有UVRect属性,只有它才能动态修改纹理坐标),,用来做游戏地图滚动背景。再把sky的贴图属性改成Texture(只有这种模式才能repeat纹理),我这个版本没有Texture属性,只有一个Default属性,两者效果一样的。再把Wrap Mode改成repeat,最后Apply。
3.把背景地图拖进sky节点的贴图属性,set native size。设置大小(512X1024)和缩放比例(X:1.25 Y:1.25),只要覆盖Canvas节点就行,没必要太大,影响性能。
4.创建一个叫sky的脚本挂载在sky下面,用来实现地图滚动效果。
5.打开sky脚本,主要是拿到Raw Image组件,并且拿到UVRect属性,进行动态修改地图纹理坐标移动,又因为Repeat的特效,会让地图一直重复。
using UnityE
using System.C
using UnityEngine.UI;
public class sky : MonoBehaviour {
  //背景图片移动的速度设置
public float speed = <span style="color: #.1f;
  //创建一个RawImage用来操作组件实例
private RawI
// Use this for initialization
void Start () {
this.img = this.GetComponent&RawImage&();
// Update is called once per frame
void Update () {
float sy = this.speed * Time.deltaT
Rect uvrect = this.img.uvR//不是传引用
uvrect.y +=
this.img.uvRect =
步骤八&&&&&&创建一个飞机,能让它被自由的移动和拖动
1.给game_root创建一个叫plane的空子节点,在plane节点下面创建一个叫anim的Image类型的动画子节点。
2.把飞机贴图拖进anim节点,set native size,节点大小设置大一点,让飞机大一点。
3.创建一个叫plane的脚本挂载在plane节点下面,用来实现飞机被鼠标自由的移动和拖动的效果。
4..打开plane脚本,先实现飞机被鼠标自由的移动和拖动;的效果
using UnityE
using System.C
public class plane : MonoBehaviour {
  //飞机随着鼠标运动需要定义飞机坐标和鼠标坐标
Vector3 start_plane_ // 按钮按下的时候飞机的起始坐标
Vector3 start_mouse_ // 鼠标的起始坐标;
// Use this for initialization
void Start () {
//这里有一个问题就是鼠标不按在飞机上,飞机也会跟着移动,这是还没有处理碰撞的原因,后面会改
//屏幕坐标转世界坐标我的理解是把摄像机拍的二维平面坐标,也就是我们鼠标点击的那个坐标,转化为三维世界的坐标,三维世界的坐标才能做一些动作。
// 响应我们的鼠标事件,GetMouseButton(0)
// Update is called once per frame
void Update () {
if (Input.GetMouseButtonDown(<span style="color: #)) { // 鼠标按下的情况
// 世界坐标来记录
// 记录一下当前鼠标的位置,获得鼠标的初始点击位置
this.start_mouse_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
// 记录一下当前我们飞机的位置,获得飞机的初始位置
this.start_plane_pos = this.transform.
else if (Input.GetMouseButton(<span style="color: #)) {
// 鼠标在滑动的情况
Vector3 w_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector3 offset = w_pos - this.start_mouse_//获得偏移量
this.transform.position = this.start_plane_pos +//设置飞机偏移后的位置
上次说过,这里有一个问题就是鼠标不按在飞机上,也可以移动飞机,这是因为没有在鼠标控制飞机前判断鼠标是否点在飞机上,所以这里的代码修改如下
打开plane脚本
using System.C
using System.Collections.G
using UnityE
using UnityEngine.UI;
public class plane : MonoBehaviour {
//飞机随着鼠标运动需要定义飞机坐标和鼠标坐标
Vector3 start_plane_
Vector3 start_mouse_
//-----修改-----
private bool is_touch = false;//是否点到飞机
// Use this for initialization
void Start () {
// Update is called once per frame
void Update () {
//鼠标按下的情况
if(Input.GetMouseButtonDown(<span style="color: #))
   //-----修改-----
    this.is_touch = false;//每次鼠标点下去,不管有没有点到飞机,初始化为没点到
 Ray myRay = Camera.main.ScreenPointToRay(Input.mousePosition);//从摄像机发出一条射线
 RaycastHit2D hit = Physics2D.Raycast(new Vector2(myRay.origin.x, myRay.origin.y), Vector2.zero);//射线从鼠标点击屏幕的那个点出发,射到以当前点击位置为原点的坐标系中的垂直于(0,0)的位置,
                                                             //如果从3D的视角看就是摄像机的射线垂直射到Canvas上
 if (hit.collider)//如果碰到有Collider2D组件的物体,就做一些事情
 if (hit.transform.gameObject.name == "plane")//如果碰到的是飞机
 //Debug.Log(hit.transform.name);//打印出碰撞到的节点的名字
 this.is_touch = true;//点到飞机
 if (is_touch)//如果点到飞机
 //获得鼠标的初始点击位置
 this.start_mouse_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
 //获得飞机的初始位置
 this.start_plane_pos = this.transform.
//鼠标滑动的情况
else if (Input.GetMouseButton(<span style="color: #) && this.is_touch)
Vector3 w_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//获得偏移量
Vector3 offset = w_pos - this.start_mouse_
//设置飞机偏移后的位置
this.transform.position = this.start_plane_pos +
步骤九&&&&&&创建一个子弹,能够在物理引擎的控制下发射出去
1.给game_root创建一个叫bullet_root的空子节点,在bullet_root节点下面创建一个叫plane_bullet的Image类型的子节点,Hierarchy视图中把bullet_root节点移动到plane节点的上面,这样子弹不会跑到飞机上面去。
2.把plane_bullet节点的大小设置为width:10,height:14,颜色为红色。
3.准备要给子弹添加刚体组件和碰撞形状组件,所以要先进行物理引擎设置edit --& ProjectSetting --&Physices 2D;设置重力为0
4.给子弹添加Rigidbody 2D刚体组件,打钩Freeze Rotation,不然子弹在碰撞过程中旋转。又因为子弹的碰撞是连续的(比较特殊),所以Collision Detection设置为Continuous
5.给子弹添加碰撞形状检测器组件,设置碰撞检测器的大小,再在物理引擎设置器中设置碰撞检测器的边界框的颜色,再打钩always show coll总是显示边界框。
6.创建一个叫plane_bullet的脚本挂载在plane_bullet节点下面,用来实现子弹飞行和飞出半个屏幕后消失的效果。
using UnityE
using System.C
public class plane_bullet : MonoBehaviour {
   //设置子弹的速度
public float speed = <span style="color: #; // 子弹的飞行速度
   //什么时候删除我们的子弹,因为设计分辨率是640X960,但是如果改变了分辨率,
//就不会还是半个屏幕的时候子弹消失,所以要转换设计分辨率的屏幕的高成具体的分辨率高,
//有一个scale比例,转换完再乘0.5f就可以取一半屏幕高
   private float dead_line_y;    Rigidbody2D
// Use this for initialization
void Start () {
this.body = this.GetComponent&Rigidbody2D&();
Vector2 v = new Vector2(<span style="color: #, this.speed);
     //刚体的运动会带动与它相连接的整个节点的运动
this.body.velocity =
float scale = <span style="color: #0.0f / (float)Screen.
this.dead_line_y = Screen.height * scale * <span style="color: #.5f;
//Debug.Log("this.dead_line_y: " + this.dead_line_y);
// Update is called once per frame
void Update () {
// 找准已给时机来删除我们的子弹;这里原点是屏幕中心,所以只要超过一半屏幕的高度就删除子弹。
if (this.transform.localPosition.y &= this.dead_line_y) {
MonoBehaviour.Destroy(this.gameObject);
步骤十&&&&&&产生一个预制体,让这个飞机不断的射击
1.为了飞机不断地射击,不断地产生子弹,需要把子弹变成预制体,就是把刚才设计的子弹变成一个模板,后面可以不断地用这个模板生成子弹。
2.在Resources文件夹下面创建一个prefabs文件夹,里面存放子弹预制体,也就是直接把plane_bullet节点拖动到prefabs文件夹下面,原节点名字变蓝。
3.打开飞机节点下的plane脚本,里面添加让飞机不断通过子弹预制体产生子弹的实现代码
要添加三个public的Inspector视图属性,一个放预制体,一个放目标父节点,也就是生成的一大堆子弹等下放在哪里,一个是子弹发射的频率,这里分别拖进plane_bullet和bullet_root和自定义频率数值。
4.打开plane脚本
using UnityE
using System.C
public class plane : MonoBehaviour
//飞机随着鼠标运动需要定义飞机坐标和鼠标坐标
Vector3 start_plane_ // 按钮按下的时候飞机的开始的坐标
Vector3 start_mouse_ // 鼠标开始的坐标;
//子弹预制体
public GameObject bullet_//预制体子弹节点
public Transform bullet_//预制体子弹节点的父节点
public float shoot_rate = <span style="color: #.2f; // 子弹发射的频率;我感觉是一个时间间隔,设定的子弹发射时间间隔
private float shoot_time = <span style="color: #.0f; // 距离上一次发射过去的时间
private bool is_shooting = false;//是否处于发射子弹的状态
//-----优化-----
private bool is_touch = false;//是否点到飞机
// Use this for initialization
void Start()
void shoot_bullet()
//使用预制体生成一颗子弹
GameObject bullet = GameObject.Instantiate(this.bullet_prefab);
// 注意这个参数要使用false,和Canvas的实现机制有关,false意思是不用世界坐标
bullet.transform.SetParent(this.bullet_root, false);
//使用localPosition是因为子弹和plane都有相同的父节点,两者之间是相对坐标
Vector3 offset = new Vector3(<span style="color: #, <span style="color: #, <span style="color: #);
//之所以用localPosition是因为子弹和飞机都是同一个父节点的子节点
bullet.transform.localPosition = this.transform.localPosition +
// 响应我们的鼠标事件,GetMouseButton(0)
void Update()
//鼠标按下的情况
if (Input.GetMouseButtonDown(<span style="color: #))
//-----修改-----
this.is_touch = false;//每次鼠标点下去,不管有没有点到飞机,初始化为没点到
Ray myRay = Camera.main.ScreenPointToRay(Input.mousePosition);//从摄像机发出一条射线
RaycastHit2D hit = Physics2D.Raycast(new Vector2(myRay.origin.x, myRay.origin.y), Vector2.zero);//射线从鼠标点击屏幕的那个点出发,射到以当前点击位置为原点的坐标系中的垂直于(0,0)的位置,
                                                               //如果从3D的视角看就是摄像机的射线垂直射到Canvas上
if (hit.collider)//如果碰到有Collider2D组件的物体,就做一些事情
if (hit.transform.gameObject.name == "plane")//如果碰到的是飞机
//Debug.Log(hit.transform.name);//打印出碰撞到的节点的名字
this.is_touch = true;//点到飞机
if (is_touch)//如果点到飞机
//获得鼠标的初始点击位置
this.start_mouse_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//获得飞机的初始位置
this.start_plane_pos = this.transform.
//鼠标滑动的情况
else if (Input.GetMouseButton(<span style="color: #) && this.is_touch)
Vector3 w_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//获得偏移量
Vector3 offset = w_pos - this.start_mouse_
//设置飞机偏移后的位置
this.transform.position = this.start_plane_pos +
// 子弹发射逻辑控制,update里面嵌套自定义的update,自定义刷新函数
this.shoot_update(Time.deltaTime);
void shoot_update(float dt)
if (!this.is_shooting)
this.shoot_time +=
if (this.shoot_time & this.shoot_rate)
this.shoot_time = <span style="color: #;
this.shoot_bullet();
5.然后可以把愿来Hierarchy视图里面蓝色名字的子弹节点plane_bullet删除
步骤十一&&&&&&修改开始,让玩家获得开始消息
1.给总的游戏控制脚本game_scene添加游戏开始的代码,就是点击按钮后触发游戏开始,飞机开始发射子弹。
2.打开game_scene脚本
using UnityE
using System.C
public class game_scene : MonoBehaviour {
   //设置一个开始游戏的标志
   bool is_started = false;
//定义plane脚本,为了等一下执行里面的start_game方法,这个方法可以让子弹开始发射
private plane player_
// Use this for initialization
void Start () {
     //获得plane脚本
this.player_ctrl = this.transform.Find("game_root/plane").GetComponent&plane&();
   //执行plane脚本里面的start_game函数开始发射子弹
private void game_realy_started() {
this.player_ctrl.start_game();//开始发射子弹
   //删除菜单节点函数
private void delete_menu() {
MonoBehaviour.Destroy(GameObject.Find("Canvas/menu_root"));
//菜单按钮点击后的响应函数,记得要设置为public权限才能关联按钮
public void on_game_start_click() {
if (this.is_started) { // 防止重复点击
this.is_started = true;
//执行一个定时器(自带的),让删除节点的函数过一会再执行,场景过渡效果
this.Invoke("delete_menu", <span style="color: #.2f);
this.Invoke("game_realy_started", <span style="color: #.0f);
// Update is called once per frame
void Update () {
3.打开plane脚本,里面添加游戏开始的触发函数
using UnityE
using System.C
public class plane : MonoBehaviour
//飞机随着鼠标运动需要定义飞机坐标和鼠标坐标
Vector3 start_plane_ // 按钮按下的时候飞机的开始的坐标
Vector3 start_mouse_ // 鼠标开始的坐标;
//子弹预制体
public GameObject bullet_//预制体子弹节点
public Transform bullet_//预制体子弹节点的父节点
public float shoot_rate = <span style="color: #.2f; // 子弹发射的频率;我感觉是一个时间间隔,设定的子弹发射时间间隔
private float shoot_time = <span style="color: #.0f; // 距离上一次发射过去的时间
private bool is_shooting = false;//是否处于发射子弹的状态
//-----优化-----
private bool is_touch = false;//是否点到飞机
// Use this for initialization
void Start()
public void start_game()
this.is_shooting = true;
void shoot_bullet()
//使用预制体生成一颗子弹
GameObject bullet = GameObject.Instantiate(this.bullet_prefab);
// 注意这个参数要使用false
bullet.transform.SetParent(this.bullet_root, false);
//使用localPosition是因为子弹和plane都有相同的父节点,两者之间是相对坐标
Vector3 offset = new Vector3(<span style="color: #, <span style="color: #, <span style="color: #);
bullet.transform.localPosition = this.transform.localPosition +
// 响应我们的鼠标事件,GetMouseButton(0)
void Update()
//鼠标按下的情况
if (Input.GetMouseButtonDown(<span style="color: #))
//-----修改-----
this.is_touch = false;//每次鼠标点下去,不管有没有点到飞机,初始化为没点到
Ray myRay = Camera.main.ScreenPointToRay(Input.mousePosition);//从摄像机发出一条射线
RaycastHit2D hit = Physics2D.Raycast(new Vector2(myRay.origin.x, myRay.origin.y), Vector2.zero);//射线从鼠标点击屏幕的那个点出发,射到以当前点击位置为原点的坐标系中的垂直于(0,0)的位置,
                                                        //如果从3D的视角看就是摄像机的射线垂直射到Canvas上
if (hit.collider)//如果碰到有Collider2D组件的物体,就做一些事情
if (hit.transform.gameObject.name == "plane")//如果碰到的是飞机
//Debug.Log(hit.transform.name);//打印出碰撞到的节点的名字
this.is_touch = true;//点到飞机
if (is_touch)//如果点到飞机
//获得鼠标的初始点击位置
this.start_mouse_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//获得飞机的初始位置
this.start_plane_pos = this.transform.
//鼠标滑动的情况
else if (Input.GetMouseButton(<span style="color: #) && this.is_touch)
Vector3 w_pos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//获得偏移量
Vector3 offset = w_pos - this.start_mouse_
//设置飞机偏移后的位置
this.transform.position = this.start_plane_pos +
// 子弹发射逻辑控制,update里面嵌套自定义的update,自定义刷新函数
this.shoot_update(Time.deltaTime);
void shoot_update(float dt)
if (!this.is_shooting)
this.shoot_time +=
if (this.shoot_time & this.shoot_rate)
this.shoot_time = <span style="color: #;
this.shoot_bullet();
阅读(...) 评论()

我要回帖

更多关于 权限管理系统制作难点 的文章

 

随机推荐