zoukankan      html  css  js  c++  java
  • 模拟帧频率。。。

    int runTime=1000*5;
            int FrameRate=1000/6;
            int checkTime=FrameRate;
            
            long startTime=new Date().getTime();
            while(runTime>checkTime)
            {
                //checkValue=moveVector3(90, checkValue);
                //checkValue.print();
                checkTime+=FrameRate;
                System.out.println(checkTime);
                try {
                    Thread.sleep(FrameRate);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            long endTime=new Date().getTime();
            System.out.println(endTime-startTime);

    修正延时

    public static void main(String[] args)
        {
            int runTime=1000;
            int FrameRate=1000/6;
            int checkTime=FrameRate;
            long startTime,entTime;
           
            long checkSTime=new Date().getTime();
            int i=0;
            while(runTime>checkTime)
            {
                System.out.println(i);
                startTime =new Date().getTime();
                try {
                    Thread.sleep(300);
                } catch (InterruptedException e1) {
                    e1.printStackTrace();
                }
                entTime=new Date().getTime();
                
                long check=entTime-startTime;
                if(check<FrameRate)
                    checkTime+=FrameRate;
                else
                    checkTime+=check;
                i++;
                try {
                    if(check<FrameRate)
                        Thread.sleep(FrameRate-check);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
            }
            System.out.println("time : " +( new Date().getTime()-checkSTime));
            
        }
  • 相关阅读:
    input 正则
    .net ashx Session 未将对象引用到实例
    js 时间和时间对比
    c# Repeater 和 AspNetPager
    c#后台 极光推送到Android 和IOS客户端
    select scope_identity()
    redhat7.4安装git(按照官网从源码安装)
    redhat7.4安装gitlab
    ES6模板字符串
    初次接触webpack
  • 原文地址:https://www.cnblogs.com/solq/p/2650720.html
Copyright © 2011-2022 走看看