zoukankan      html  css  js  c++  java
  • 2019.10.30 拖拽IBeginDragHandler、IDragHandler、和IEndDragHandler这三个接口的应用 以及技能消耗品冷却效果

    来源:https://blog.csdn.net/qq_33552377/article/details/78273290

    今天主要熟悉了拖拽IBeginDragHandler、IDragHandler、和IEndDragHandler这三个接口的应用
    IBeginDragHandle开始拖动要做的事  IEndDragHandler结束拖动应该做的事
    卡片类拖拽方法:继承IDropHandler, IPointerEnterHandler, IPointerExitHandler这三个接口
    IDropHandel OnDrop 处理松开鼠标左键事应该做什么事   IPointerEnterHandler OnPointEnter处理鼠标指针进入挂在该脚本的物体区域时要做什么事IPointerExitHandler OnPointerExit处理鼠标移除该挂载脚本的物体区域时要做什么事
    以及消耗品技能的冷却效果
    冷却效果的呈现需复制以相同的技能图片改变其图片的透明度 改变其ImageType 属性为Filled  通过代码获取其FillAmount 来控制其冷却效果
    效果如下:

    代码如下
    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    using UnityEngine.UI;
    public class clicklengque : MonoBehaviour {
        public Image img;  //获取Img
        bool isStart = false;
        float col = 2; //设置冷却时间
        float time = 0; //设置现在时间
     // Use this for initialization
     void Start () {
      
     }
         //Time.deltaTime 把时间平均分配到每一帧里
        // Update is called once per frame
        void Update() {
            if (isStart)
            {
                time += Time.deltaTime;    //现在的时间=已经过去的时间+每一帧的正在进行的时间
                img.fillAmount = (col - time) / col; //用冷却时间减去现在时间除以冷却时间算出现在冷却时间的百分比将赋其给图片
                if (time >= col)      //如果现在时间大于冷却时间则冷却完毕 
                {
                    img.fillAmount = 0;  将图片占比改为0
                    time = 0;         //将现在时间改为0
                    isStart = false;  
                }
            }
        }
        public void click()
        {
            isStart = true;
        }
    }
    ————————————————
    版权声明:本文为CSDN博主「JOSUNY」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。
    原文链接:https://blog.csdn.net/qq_33552377/article/details/78273290

  • 相关阅读:
    User Get 'Access Denied' with Excel Service WebPart
    How To Search and Restore files from Site Collection Recycle Bin
    How To Collect ULS Log from SharePoint Farm
    How To Restart timer service on all servers in farm
    How to Operate SharePoint User Alerts with PowerShell
    How to get Timer Job History
    Synchronization Service Manager
    SharePoint 2007 Full Text Searching PowerShell and CS file content with SharePoint Search
    0x80040E14 Caused by Max Url Length bug
    SharePoint 2007 User Re-created in AD with new SID issue on MySite
  • 原文地址:https://www.cnblogs.com/LiTZen/p/11766512.html
Copyright © 2011-2022 走看看