zoukankan      html  css  js  c++  java
  • Laya 分帧加载优化

    Laya 分帧加载优化

    @author ixenos 

    Flash中的EnterFrame事件在Laya中等同于Laya.timer.frameLoop(1,...)

     1 Laya.timer.frameLoop(1, this, onFrame);
     2 
     3 var curIdx:int = 0;
     4 
     5 var st:Number = 0;
     6 
     7 var tLimit:Number = 1000/Laya.timer.currFrame*0.25;//最大时间不超过一帧所需时间的25%(可调整)
     8 
     9 function onFrame():void{
    10 
    11   st = new Date().getTime();
    12   for(var i:int = curIdx; i < MAX_COUNT; i++){
    13     //到达时限时,余下script不在当前帧运行
    14     if(new Date().getTime() - st > tLitmit){
    15       curIdx = i;
    16       return;
    17     }
    18     doThings();
    19   }
    20 
    21   onComplete();
    22 
    23 }
    24 
    25 
    26 
    27 function doThings(){
    28 
    29 }
    30 
    31 
    32 
    33 function onComplete(){
    34 
    35   Laya.timer.clear(this, onFrame);
    36 
    37 }
  • 相关阅读:
    (一)maven基本配置,概念,常用命令
    redis 小结
    git 小结
    spring.xml
    servlet web.xml学习笔记
    springmvc小试牛刀
    maven
    springmvc学习笔记1
    springmvcpojo
    springmvc学习笔记
  • 原文地址:https://www.cnblogs.com/ixenos/p/9952684.html
Copyright © 2011-2022 走看看