UGUI 之 制作角色受伤屏幕变红的动画提示(三)
2016-06-30 14:58
411 查看
做一个FPS设计游戏中常用的角色受伤后的屏幕变红提示
一、源代码
[csharp] view
plain copy
print?
/// <summary>
/// 时间:2014-4-8
/// 作者:GWL
/// 描述:
/// </summary>
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PlayerDamageAnim : MonoBehaviour {
public Image damage_Image;
public Color flash_Color;
public float flash_Speed = 5;
bool damaged = false;
// Update is called once per frame
void Update () {
//测试的输入代码段
if(Input.GetMouseButtonDown(0)){
TakeDamage();
}
PlayDamagedEffect ();
}
/// <summary>
/// 角色受伤后的屏幕效果
/// </summary>
void PlayDamagedEffect(){
if (damaged) {
damage_Image.color = flash_Color;
} else {
damage_Image.color = Color.Lerp(damage_Image.color,Color.clear,flash_Speed * Time.deltaTime);
}
damaged = false;
}
/// <summary>
/// 角色受伤
/// </summary>
public void TakeDamage(){
damaged = true;
}
}
二、截图
一、源代码
[csharp] view
plain copy
print?
/// <summary>
/// 时间:2014-4-8
/// 作者:GWL
/// 描述:
/// </summary>
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class PlayerDamageAnim : MonoBehaviour {
public Image damage_Image;
public Color flash_Color;
public float flash_Speed = 5;
bool damaged = false;
// Update is called once per frame
void Update () {
//测试的输入代码段
if(Input.GetMouseButtonDown(0)){
TakeDamage();
}
PlayDamagedEffect ();
}
/// <summary>
/// 角色受伤后的屏幕效果
/// </summary>
void PlayDamagedEffect(){
if (damaged) {
damage_Image.color = flash_Color;
} else {
damage_Image.color = Color.Lerp(damage_Image.color,Color.clear,flash_Speed * Time.deltaTime);
}
damaged = false;
}
/// <summary>
/// 角色受伤
/// </summary>
public void TakeDamage(){
damaged = true;
}
}
二、截图
相关文章推荐
- UGUI 之 Canvas布局层级关系(一)
- [界面开发新秀]免费的AYUI,开发360领航版系列教程[2/40]
- pip安装pyquery报错
- 关于stm32报错Library reports error: __use_no_semihosting was requested
- project 2013 安装程序找不到office.zh-cn\officeMUI.xml
- iOS 查看UI控件层次结构的方法
- 阿里Druid连接池配置使用
- 【腾讯TMQ】解放程序猿(媛)的双手—iOS UI自动化测试
- GL.IssuePluginEvent 发布插件事件
- 在有Textfield的页面,键盘弹出效果
- UITabBarController作为根视图控制器的时候出现的问题,popToRootViewController的时候出现两个TabBar
- MySQL慢查询可视化(1):pt-query-digest + Anemometer
- BZOJ2632: [neerc2011]Gcd guessing game
- 修复 Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.8:add-source (execution: add-source, phase: generate-sources)
- 并发队列ConcurrentLinkedQueue和阻塞队列LinkedBlockingQueue用法
- MiniUI - 专业WebUI控件库
- easyui textBox的点击事件
- newlisp quick sort增强
- easyui-combobox的取值问题
- UI design principles