zibll子比主题美化 Zibll主题添加FPS帧率显示

作者:晓白pos网 发布时间:2022-07-09 21:01:07

前言

你们打游戏都有显示游戏帧率吧,其实网站也能显示,具体显示为xxFPS,只要一句js代码即可在你的子比主题上实现,效果图不展示了,但是晓白保证绝对有效,因为我不想测试(懒得动)

使用教程

网站管理后台—主题设置—自定义代码—自定义javascript代码

这是具体代码的使用路径,子比主题专用的路径,其实其他主题也能用,这里不多说

代码如下

[hidecontent type="reply"]

// FPS帧 晓白博客网
$('body').before('<div id="fps" style="z-index:10000;position:fixed;top:3;left:3;font-weight:bold;"></div>');
var showFPS = (function(){ 
    var requestAnimationFrame =  
        window.requestAnimationFrame || 
        window.webkitRequestAnimationFrame || 
        window.mozRequestAnimationFrame ||
        window.oRequestAnimationFrame ||
        window.msRequestAnimationFrame || 
        function(callback) { 
            window.setTimeout(callback, 1000/60); 
        }; 
    var e,pe,pid,fps,last,offset,step,appendFps; 
 
    fps = 0; 
    last = Date.now(); 
    step = function(){ 
        offset = Date.now() - last; 
        fps += 1; 
        if( offset >= 1000 ){ 
        last += offset; 
        appendFps(fps); 
        fps = 0; 
        } 
        requestAnimationFrame( step ); 
    }; 
    appendFps = function(fps){ 
        console.log(fps+'FPS');
        $('#fps').html(fps+'FPS');
    };
    step();
})();

[/hidecontent]上面的代码复制粘贴即可

教程结束

25776035f2210148
标签:, , , , ,

联系邮箱:ert5tyx@163.com(三个工作日内处理)
Copyright © 2020 · 晓白pos网 皖ICP备2022013394号-7