unity3d 生命槽的设置
来源:互联网 发布:网易房产数据 上海 编辑:程序博客网 时间:2024/05/19 16:23
最近看一个视频教程 主要讲对砍rpg的制作 为了提高学习效率 所以适当的做下笔记,也方便以后查找
首先将第一人称的控制器拖入到场景中命名为player 并添加脚本(主要用c#)
代码如下
运行后的效果如下,看上去还是太简陋了。。using UnityEngine;using System.Collections;public class PlayHealth : MonoBehaviour {public int maxhealth=100; //最大生命值public int curhealth=100; //当前生命值public float health; //血条的长度// Use this for initializationvoid Start () {health=Screen.width/2; //将血条长度定义为屏幕的一般长}// Update is called once per framevoid Update () {addjustcurhealth(0);}void OnGUI(){GUI.TextArea(new Rect(10,20,30,20),"HP");GUI.Box(new Rect(40,20,health,20),curhealth+"/"+maxhealth);//用gui绘制血条}void addjustcurhealth(int adj) //血条长度变化函数{ curhealth+=adj;if(curhealth<0)curhealth=0;if(curhealth>maxhealth)curhealth=maxhealth;if(maxhealth<1)maxhealth=1;health=Screen.width/2*(curhealth/(float)maxhealth);}}
- unity3d 生命槽的设置
- Unity3d之生命槽设置
- Unity3D之Position的设置
- Unity3D Raycast, LayerMask的设置
- unity3d设置材质的shader
- 【Unity3D】【NGUI】如何设置Atlas的Texture
- Unity3D 设置GameObjet 的隐藏和显示
- unity3D获取和设置鼠标的位置
- unity3d 4.6RectTransform 的一些设置
- Unity3D之UILabel的属性设置
- 【Unity3D】设置不打开上次的项目
- Unity3d设置鼠标指针的样式
- 感悟生命、尊重生命 唤醒人的生命意识
- 人工生命与生命的本质
- 感受生命的伟大,努力绽放生命!
- 生命的方向
- 生命的价值
- 生命的空隙
- C++ Data Structure 2
- 深入浅出Node.js(一):什么是Node.js
- 虚函数
- java基础——泛型(jdk1.5新特性)
- JS的验证信息
- unity3d 生命槽的设置
- 教学任重道远 专家“保驾护航”——国家外专局特派专家提升AYC培训质量
- hdu - 3260 - Facer is learning to swim(dfs)
- linux命令连接符与替换符
- 短信验证码倒计时
- “快用助手”动起苹果商店奶酪
- 个人评测酷盘 kanbox 网络硬盘的使用体验
- android setTag (int key, Object tag)抛出IllegalArgumentException的问题
- jQuery获取Select选择的Text和 Value(转)