<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      代碼改變世界

      怎么把CanvasLoading插件嵌入你的游戲

      2011-12-07 17:01  【當(dāng)耐特】  閱讀(3486)  評論(3)    收藏  舉報

      一.簡介

      CanvasLoading插件適用于任何基于Canvas游戲的loading過程展示。

      Untitled

       

      二.插件源碼

              Loading = function (text, fontSize,baseFontSize, color, position, interval, font, bolder) {
                  this.text = text;
                  this.fontSize = fontSize;
                  this.baseFontSize=baseFontSize;
                  this.color = color;
                  this.position = position;
                  this.interval = interval;
                  this.font = font;
                  this.bolder = bolder;
                  return this.init();
              }
         
              Loading.prototype.init = function () {
                  var text = [];
                  var _this = this;
                  var words = _this.text.split("");
                  for (i in words) {
                      text.push({
                          "text": words[i],
                          "fontSize": _this.fontSize,
                          "baseFontSize":_this.baseFontSize,
                          "color": _this.color,
                          "position": new Vector2(_this.position.x + i * _this.interval, _this.position.y),
                          "font": _this.font,
                          "bolder":_this.bolder
                      });
      
                  }
                  return text;
              }
      
              Vector2 = function (x, y) {
                  this.x = x || 0;
                  this.y = y || 0;
              };
      
      
              var loading = new Loading("this is loading canvas", 30, 30,"#ffffff", new Vector2(20, 80), 15, "宋體", "bolder");
              var loadingCanvas = document.createElement('canvas');
              loadingCanvas.width = 420;
              loadingCanvas.height = 100;
      
              var cxt = loadingCanvas.getContext("2d");
              cxt.fillStyle = loading[0].color;
              function drawLoading() {
                  for (i in loading) {            
                      cxt.font = loading[i].bolder + " " + loading[i].fontSize + "px " + loading[i].font;
                      cxt.fillText(loading[i].text, loading[i].position.x, loading[i].position.y);
                  }
      
              }
              var currentMap = 0;
              function changeFontSize() {
                  if (currentMap > 895) currentMap = 0;
                  currentMap += 5;
                  if (parseInt(currentMap / 40) <= loading.length - 1) {
                      loading[parseInt(currentMap / 40)].fontSize = 2 * loading[0].baseFontSize - currentMap % 40;
                  }
                  if (parseInt(currentMap / 40) + 1 <= loading.length - 1) {
      
                      loading[parseInt(currentMap / 40) + 1].fontSize = currentMap % 40 + loading[0].baseFontSize;
                  }
              }
              function draw() {
                  cxt.clearRect(0, 0, loadingCanvas.width, loadingCanvas.height);
                  drawLoading();
                  changeFontSize();
              }
              setInterval(draw, 10);
      

      三.插件使用

              var canvas = document.getElementById("myCanvas");
              var context = canvas.getContext('2d');
              context.font = "bolder 40px 宋體";
              context.fillStyle = "#ffffff";
              var gameLoadingAsync = eval(Jscex.compile("async", function () {
                  while (true) {
                      context.clearRect(0, 0, canvas.width, canvas.height);
                      context.drawImage(loadingCanvas, 0, 0);
                      context.fillText("this is game canvas!", 10, 38);
                      $await(Jscex.Async.sleep(10));
                  }
              }))
              gameLoadingAsync().start();
      

       

      四.插件講解

      在上面出現(xiàn)了兩個Canvas,一個是頁面當(dāng)中的Canvas,用于顯示游戲內(nèi)容。另外一個是create出來的canvas,用于存儲loading里動態(tài)信息以便寫到頁面當(dāng)中的canvas.

      原理:把內(nèi)存中的動態(tài)loadingCanvas寫入你的游戲Canvas當(dāng)中。這其實和把視頻寫入canvas一個思路,也是把動態(tài)的內(nèi)容寫入canvas.比如HTML5實驗室【二十八】—Canvas+Video打造酷炫播放體驗

      五.在線演示

      Your browser does not support the canvas element.

      六.同步

      本文已同步更新至:

      HTML5實驗室【目錄】:   http://www.rzrgm.cn/iamzhanglei/archive/2011/11/06/2237870.html

      主站蜘蛛池模板: 色香欲天天影视综合网| 亚洲Av综合日韩精品久久久| 精品免费看国产一区二区| 99热成人精品热久久66| 丁香五月婷激情综合第九色| 中文字幕人成乱码熟女| 欧美xxxx精品另类| 亚洲中文字幕无码中字| 亚洲精品久久麻豆蜜桃| 内射视频福利在线观看| 国产成人精品国产成人亚洲| 大地资源中文在线观看西瓜| 国产在线拍偷自揄观看视频网站| 亚洲国产成人综合精品| 国模少妇无码一区二区三区| 久久无码专区国产精品| 免费无码一区无码东京热| 干老熟女干老穴干老女人| 国产久免费热视频在线观看| 国产真实露脸乱子伦原著| 亚洲一区二区三区18禁| 亚洲欧美综合中文| 国内精品久久久久久无码不卡| 国产一区二区三区不卡观| 偷拍精品一区二区三区| 久久久精品94久久精品| 人妻加勒比系列无码专区| 亚洲欧洲日产国无高清码图片| 国产亚洲欧美精品久久久| 久久91精品牛牛| 国产成人午夜一区二区三区| 成 人 色 网 站免费观看| 国产午夜精品理论大片| 亚洲Av综合日韩精品久久久| 国产网曝门亚洲综合在线 | 99精品国产在热久久婷婷| 人妻系列中文字幕精品| a级黑人大硬长爽猛出猛进| 2019国产精品青青草原| 伊人色综合一区二区三区影院视频| 国产精品成人久久电影|