|
unity3d在设置图片路径信息的时候需要注意较多的路径设置问题,因为unity3d的图片路径和其他的操作软件的路径是不一样的,它有自己的特殊性,在操作过程中如果不能够达到规定的操作要求,就会导致unity3d的图片路径反馈出现问题。现在我们来深入的看看unity3d的图片路径信息的具体内容。temp包含了两种类型的图片路径信息:地图图片路径和玩家图片路径。因此,将其分离为map和player: var map = [{ id: "ground", url: getImages("ground") }, { id: "wall", url: getImages("wall") } ]; var player = [{ id: "player", url: getImages("player") }];提出_addImg在_getImg中提出“加入图片”职责,形成_addImg方法:var _getImg = function () { var urls = []; varGetPath和ImgPathData(function () { var getPath = (function () { var urlPre = "../Content/Image/"; var imgPathData = { ground: "Map/ground.png", wall: "Map/wall.png", player: "Player/player.png" }; return function (id) { return urlPre + imgPathData[id]; };}()); window.getPath = getPath;}());Mainvar _getImg = function () { var urls = []; var i = 0, len = 0; var map = [ { id: "ground", url: getPath("ground") }, { id: "wall", url: getPath("wall") } ]; var player = [ { id: "player", url: getPath("player") } ]; _addImg(urls, map, player); return urls;};var _addImg = function (urls, imgs) { var args = Array.prototype.slice.call(arguments, 1), i = 0, j = 0, len1 = 0, len2 = 0; for (i = 0, len1 = args.length; i < len1; i++) { for (j = 0, len2 = args.length; j < len2; j++) { urls.push({ id: args[j].id, url: args[j].url }); } }}; var Animation = YYC.Class({ Init: function (config) { this._frames = YYC.Tool.array.clone(config.frames); //config.img为HtmlImg对象 this._img = config.img; this._init(); }, Private: { // Animation 包含的Frame, 类型:数组 _frames: null, // 包含的Frame数目 _frameCount: -1, _img: null, _currentFrame: null, _currentFrameIndex: -1, _currentFramePlayed: -1, _init: function () { this._frameCount = this._frames.length; this.setCurrentFrame(0); } }, Public: { setCurrentFrame: function (index) { this._currentFrameIndex = index; this._currentFrame = this._frames[index]; this._currentFramePlayed = 0; unity3d的图片路径信息还会涉及到一些技术上的问题,主要是unity3d的基础操作技术。因此大家在学习unity3d的图片路径信息操作的时候还要注意看看unity3d的的基础操作问题。
|