实现图片加载进度
LoadingSample Class
用来显示进度条的对象。
引擎中目前提供的进度条类有:LoadingSample1~7
你可以制作自己的进度条,自制进度条类中要包含setProgress函数。
//初始化引擎组件init(50, "div_caiquan", 800, 400, main);//定义游戏层,加载进度层、游戏背景层var loadingLayer, backLayer;//定义游戏图片//定义图片资源加载完成后返回的图片对象var imglist = {};//定义图片资源数组var imgData = new Array( {name:"title",path:"../images/title.png"}, { name: "shitou", path: "../images/shitou.png" }, { name: "jiandao", path: "../images/jiandao.png" }, { name: "001", path: "../images/001.jpg" }, { name: "002", path: "../images/002.jpg" }, { name: "003", path: "../images/003.jpg" }, { name: "004", path: "../images/004.jpg" }, { name: "bu", path: "../images/bu.png" } );//回调函数function main() { //创建背景层 backLayer = new LSprite(); //将背景层添加到画布 addChild(backLayer); //创建加载进度层 loadingLayer = new LoadingSample3(); //将加载进度层添加到背景层 backLayer.addChild(loadingLayer); //loadingLayer.setProgress(35); //加载图片资源 LLoadManage.load( //图片数据数组 imgData, function (progress) { //显示加载进度 loadingLayer.setProgress(progress); }, function (result) { //加载完成 //result可以认为是一个map,资源列表中的资源可以按键获取 imglist = result; //移除加载进度层 backLayer.removeChild(loadingLayer); loadingLayer = null; //游戏初始化 gameInit(); } );};//游戏初始化function gameInit() { //game begin};