unity3d-游戏实战突出重围,第二天 制作血条
2024-09-25 19:28:44
using UnityEngine;
using System.Collections; public class xt : MonoBehaviour
{ //红色血条
public Texture2D blood_red;
//黑色血条
public Texture2D blood_black;
//当前生命值
private int HP = ; void OnGUI()
{
if (GUILayout.RepeatButton("加血"))
{
//增加生命值
if (HP < )
{
HP++;
}
}
if (GUILayout.RepeatButton("减血"))
{
//减少生命值
if (HP > )
{
HP--;
}
}
//根据当前生命值计算红色血条显示的宽度
int blood_width = blood_red.width * HP / ;
//绘制黑色血条
GUI.DrawTexture(new Rect(, , blood_black.width, blood_black.height), blood_black);
//绘制红色血条
GUI.DrawTexture(new Rect(, , blood_width, blood_red.height), blood_red); }
}
资源下载
http://pan.baidu.com/s/1dDEjy9b
最新文章
- JavaScript——正则表达式
- linux复习
- http的响应对象
- View (二) 自定义属性
- PHP 设计模式 笔记与总结(2)开发 PSR-0 的基础框架
- ubuntu下安装mysql及外网访问设置
- mvc mvp mvvm区别
- php环境配置优化
- NodeJS+express+mogondb学习笔记01
- MSSQL查询数据分页
- poj 3696 The Luckiest Number
- Linux filesystem
- RoboMongo命令(版本:Robo 3T 1.1.1)
- jQuery: 选择器,筛选器
- Html的简单学习笔记
- SQL Server ->;>; DAC(Dedicated Administrator Connection)专用管理员连接
- InfluxDB中文文档
- PLSQL导出对象的表结构和表数据
- Eclipse导入包提示Setting build path has encountered a problem
- sql中exist()的用法