如何为一个非常简单的加载屏幕设置gif动画?

时间:2015-05-18 17:36:01

标签: javascript

我正在使用游戏制作工作游戏。我想创建一个非常简单的自定义加载屏幕,使用.js文件完成。因为我对java一无所知,所以我使用了预设,这是我得到的(下面)。我的gif出现在加载屏幕上,除了它没有动画(只显示第一帧)。我可以更改哪些内容,以便"customlogo.src"中的网址显示Fo动画?

感谢您的阅读。

    var window_bgd="rgb(40,40,40)";                 //Background color 
    var ls_height= _height;                     //Loading Screen image height in pixel (use _height to fit canvas)
    var ls_width= _width;                       //Loading Screen image width in pixel (use _width to fit canvas)
    var ls_y_pos=0;                             //Loading Screen image vertical position 
    var ls_x_pos=0;                             //Loading Screen image orizontal position 

    var customlogo = new Image();               //variable creation, DON'T EDIT
    customlogo.src = "<URL.gif>";                       //URL to custom image, leave empty in not needed
    var imgheight= 300;                         //custom image height in pixel (use _height to fit canvas)
    var imgwidth= 300;                          //custom image width in pixel (use _width to fit canvas)
    var fromtop=((_height - imgheight)/2);      //custom image vertical position (centered in example)
    var fromside=((_width - imgwidth)/2);       //custom image orizontal position (centered in example)

    //Color the background 
    _graphics.fillStyle = window_bgd;
    _graphics.fillRect(0, 0, _width, _height);

    //If GM splashscreen is set use it, and make it same width and height as canvas, start drawing at x=0 and y=0
    if (_loadingscreen){
    _graphics.drawImage(_loadingscreen, ls_x_pos, ls_y_pos, ls_width, ls_height);
} 
//If custom image is set use it, and make it same width and height as canvas, start drawing at x=0 and y=0

  if  (customlogo.src!="") {
    _graphics.drawImage(customlogo, fromside, fromtop, imgwidth, imgheight);
  }
}

0 个答案:

没有答案