查看: 4042|回复: 4

[有事请教] 如何在图片文件夹下创建子文件夹分类管理图片?

[复制链接]
梦石
0
星屑
953
在线时间
191 小时
注册时间
2017-10-30
回帖
23
发表于 2018-2-24 12:54:41 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
由于图片比较多,想要分类管理。。
但是经过试验目前只有第一层目录下的图片文件可正常读取,如果自己再直接建子文件夹是不行的
有没有什么方法可以解决呢?多谢
梦石
0
星屑
4399
在线时间
552 小时
注册时间
2017-12-2
回帖
41
发表于 2018-2-24 16:12:42 | 显示全部楼层
  1. //-----------------------------------------------------------------------------
  2. // ImageManager
  3. //
  4. // The static class that loads images, creates bitmap objects and retains them.

  5. function ImageManager() {
  6.     throw new Error('This is a static class');
  7. }

  8. ImageManager.cache = new CacheMap(ImageManager);

  9. ImageManager._imageCache = new ImageCache();
  10. ImageManager._requestQueue = new RequestQueue();
  11. ImageManager._systemReservationId = Utils.generateRuntimeId();

  12. ImageManager._generateCacheKey = function(path, hue){
  13.     return  path + ':' + hue;
  14. };

  15. ImageManager.loadAnimation = function(filename, hue) {
  16.     return this.loadBitmap('img/animations/', filename, hue, true);
  17. };

  18. ImageManager.loadBattleback1 = function(filename, hue) {
  19.     return this.loadBitmap('img/battlebacks1/', filename, hue, true);
  20. };

  21. ImageManager.loadBattleback2 = function(filename, hue) {
  22.     return this.loadBitmap('img/battlebacks2/', filename, hue, true);
  23. };

  24. ImageManager.loadEnemy = function(filename, hue) {
  25.     return this.loadBitmap('img/enemies/', filename, hue, true);
  26. };

  27. ImageManager.loadCharacter = function(filename, hue) {
  28.     return this.loadBitmap('img/characters/', filename, hue, false);
  29. };

  30. ImageManager.loadFace = function(filename, hue) {
  31.     return this.loadBitmap('img/faces/', filename, hue, true);
  32. };

  33. ImageManager.loadParallax = function(filename, hue) {
  34.     return this.loadBitmap('img/parallaxes/', filename, hue, true);
  35. };

  36. ImageManager.loadPicture = function(filename, hue) {
  37.     return this.loadBitmap('img/pictures/', filename, hue, true);
  38. };

  39. ImageManager.loadSvActor = function(filename, hue) {
  40.     return this.loadBitmap('img/sv_actors/', filename, hue, false);
  41. };

  42. ImageManager.loadSvEnemy = function(filename, hue) {
  43.     return this.loadBitmap('img/sv_enemies/', filename, hue, true);
  44. };

  45. ImageManager.loadSystem = function(filename, hue) {
  46.     return this.loadBitmap('img/system/', filename, hue, false);
  47. };

  48. ImageManager.loadTileset = function(filename, hue) {
  49.     return this.loadBitmap('img/tilesets/', filename, hue, false);
  50. };

  51. ImageManager.loadTitle1 = function(filename, hue) {
  52.     return this.loadBitmap('img/titles1/', filename, hue, true);
  53. };

  54. ImageManager.loadTitle2 = function(filename, hue) {
  55.     return this.loadBitmap('img/titles2/', filename, hue, true);
  56. };

  57. ImageManager.loadBitmap = function(folder, filename, hue, smooth) {
  58.     if (filename) {
  59.         var path = folder + encodeURIComponent(filename) + '.png';
  60.         var bitmap = this.loadNormalBitmap(path, hue || 0);
  61.         bitmap.smooth = smooth;
  62.         return bitmap;
  63.     } else {
  64.         return this.loadEmptyBitmap();
  65.     }
  66. };

  67. ImageManager.loadEmptyBitmap = function() {
  68.     var empty = this._imageCache.get('empty');
  69.     if(!empty){
  70.         empty = new Bitmap();
  71.         this._imageCache.add('empty', empty);
  72.         this._imageCache.reserve('empty', empty, this._systemReservationId);
  73.     }

  74.     return empty;
  75. };

  76. ImageManager.loadNormalBitmap = function(path, hue) {
  77.     var key = this._generateCacheKey(path, hue);
  78.     var bitmap = this._imageCache.get(key);
  79.     if (!bitmap) {
  80.         bitmap = Bitmap.load(path);
  81.         bitmap.addLoadListener(function() {
  82.             bitmap.rotateHue(hue);
  83.         });
  84.         this._imageCache.add(key, bitmap);
  85.     }else if(!bitmap.isReady()){
  86.         bitmap.decode();
  87.     }

  88.     return bitmap;
  89. };

  90. ImageManager.clear = function() {
  91.     this._imageCache = new ImageCache();
  92. };

  93. ImageManager.isReady = function() {
  94.     return this._imageCache.isReady();
  95. };

  96. ImageManager.isObjectCharacter = function(filename) {
  97.     var sign = filename.match(/^[\!\$]+/);
  98.     return sign && sign[0].contains('!');
  99. };

  100. ImageManager.isBigCharacter = function(filename) {
  101.     var sign = filename.match(/^[\!\$]+/);
  102.     return sign && sign[0].contains('$');
  103. };

  104. ImageManager.isZeroParallax = function(filename) {
  105.     return filename.charAt(0) === '!';
  106. };


  107. ImageManager.reserveAnimation = function(filename, hue, reservationId) {
  108.     return this.reserveBitmap('img/animations/', filename, hue, true, reservationId);
  109. };

  110. ImageManager.reserveBattleback1 = function(filename, hue, reservationId) {
  111.     return this.reserveBitmap('img/battlebacks1/', filename, hue, true, reservationId);
  112. };

  113. ImageManager.reserveBattleback2 = function(filename, hue, reservationId) {
  114.     return this.reserveBitmap('img/battlebacks2/', filename, hue, true, reservationId);
  115. };

  116. ImageManager.reserveEnemy = function(filename, hue, reservationId) {
  117.     return this.reserveBitmap('img/enemies/', filename, hue, true, reservationId);
  118. };

  119. ImageManager.reserveCharacter = function(filename, hue, reservationId) {
  120.     return this.reserveBitmap('img/characters/', filename, hue, false, reservationId);
  121. };

  122. ImageManager.reserveFace = function(filename, hue, reservationId) {
  123.     return this.reserveBitmap('img/faces/', filename, hue, true, reservationId);
  124. };

  125. ImageManager.reserveParallax = function(filename, hue, reservationId) {
  126.     return this.reserveBitmap('img/parallaxes/', filename, hue, true, reservationId);
  127. };

  128. ImageManager.reservePicture = function(filename, hue, reservationId) {
  129.     return this.reserveBitmap('img/pictures/', filename, hue, true, reservationId);
  130. };

  131. ImageManager.reserveSvActor = function(filename, hue, reservationId) {
  132.     return this.reserveBitmap('img/sv_actors/', filename, hue, false, reservationId);
  133. };

  134. ImageManager.reserveSvEnemy = function(filename, hue, reservationId) {
  135.     return this.reserveBitmap('img/sv_enemies/', filename, hue, true, reservationId);
  136. };

  137. ImageManager.reserveSystem = function(filename, hue, reservationId) {
  138.     return this.reserveBitmap('img/system/', filename, hue, false, reservationId || this._systemReservationId);
  139. };

  140. ImageManager.reserveTileset = function(filename, hue, reservationId) {
  141.     return this.reserveBitmap('img/tilesets/', filename, hue, false, reservationId);
  142. };

  143. ImageManager.reserveTitle1 = function(filename, hue, reservationId) {
  144.     return this.reserveBitmap('img/titles1/', filename, hue, true, reservationId);
  145. };

  146. ImageManager.reserveTitle2 = function(filename, hue, reservationId) {
  147.     return this.reserveBitmap('img/titles2/', filename, hue, true, reservationId);
  148. };

  149. ImageManager.reserveBitmap = function(folder, filename, hue, smooth, reservationId) {
  150.     if (filename) {
  151.         var path = folder + encodeURIComponent(filename) + '.png';
  152.         var bitmap = this.reserveNormalBitmap(path, hue || 0, reservationId || this._defaultReservationId);
  153.         bitmap.smooth = smooth;
  154.         return bitmap;
  155.     } else {
  156.         return this.loadEmptyBitmap();
  157.     }
  158. };

  159. ImageManager.reserveNormalBitmap = function(path, hue, reservationId){
  160.     var bitmap = this.loadNormalBitmap(path, hue);
  161.     this._imageCache.reserve(this._generateCacheKey(path, hue), bitmap, reservationId);

  162.     return bitmap;
  163. };

  164. ImageManager.releaseReservation = function(reservationId){
  165.     this._imageCache.releaseReservation(reservationId);
  166. };

  167. ImageManager.setDefaultReservationId = function(reservationId){
  168.     this._defaultReservationId = reservationId;
  169. };


  170. ImageManager.requestAnimation = function(filename, hue) {
  171.     return this.requestBitmap('img/animations/', filename, hue, true);
  172. };

  173. ImageManager.requestBattleback1 = function(filename, hue) {
  174.     return this.requestBitmap('img/battlebacks1/', filename, hue, true);
  175. };

  176. ImageManager.requestBattleback2 = function(filename, hue) {
  177.     return this.requestBitmap('img/battlebacks2/', filename, hue, true);
  178. };

  179. ImageManager.requestEnemy = function(filename, hue) {
  180.     return this.requestBitmap('img/enemies/', filename, hue, true);
  181. };

  182. ImageManager.requestCharacter = function(filename, hue) {
  183.     return this.requestBitmap('img/characters/', filename, hue, false);
  184. };

  185. ImageManager.requestFace = function(filename, hue) {
  186.     return this.requestBitmap('img/faces/', filename, hue, true);
  187. };

  188. ImageManager.requestParallax = function(filename, hue) {
  189.     return this.requestBitmap('img/parallaxes/', filename, hue, true);
  190. };

  191. ImageManager.requestPicture = function(filename, hue) {
  192.     return this.requestBitmap('img/pictures/', filename, hue, true);
  193. };

  194. ImageManager.requestSvActor = function(filename, hue) {
  195.     return this.requestBitmap('img/sv_actors/', filename, hue, false);
  196. };

  197. ImageManager.requestSvEnemy = function(filename, hue) {
  198.     return this.requestBitmap('img/sv_enemies/', filename, hue, true);
  199. };

  200. ImageManager.requestSystem = function(filename, hue) {
  201.     return this.requestBitmap('img/system/', filename, hue, false);
  202. };

  203. ImageManager.requestTileset = function(filename, hue) {
  204.     return this.requestBitmap('img/tilesets/', filename, hue, false);
  205. };

  206. ImageManager.requestTitle1 = function(filename, hue) {
  207.     return this.requestBitmap('img/titles1/', filename, hue, true);
  208. };

  209. ImageManager.requestTitle2 = function(filename, hue) {
  210.     return this.requestBitmap('img/titles2/', filename, hue, true);
  211. };

  212. ImageManager.requestBitmap = function(folder, filename, hue, smooth) {
  213.     if (filename) {
  214.         var path = folder + encodeURIComponent(filename) + '.png';
  215.         var bitmap = this.requestNormalBitmap(path, hue || 0);
  216.         bitmap.smooth = smooth;
  217.         return bitmap;
  218.     } else {
  219.         return this.loadEmptyBitmap();
  220.     }
  221. };

  222. ImageManager.requestNormalBitmap = function(path, hue){
  223.     var key = this._generateCacheKey(path, hue);
  224.     var bitmap = this._imageCache.get(key);
  225.     if(!bitmap){
  226.         bitmap = Bitmap.request(path);
  227.         bitmap.addLoadListener(function(){
  228.             bitmap.rotateHue(hue);
  229.         });
  230.         this._imageCache.add(key, bitmap);
  231.         this._requestQueue.enqueue(key, bitmap);
  232.     }else{
  233.         this._requestQueue.raisePriority(key);
  234.     }

  235.     return bitmap;
  236. };

  237. ImageManager.update = function(){
  238.     this._requestQueue.update();
  239. };

  240. ImageManager.clearRequest = function(){
  241.     this._requestQueue.clear();
  242. };
复制代码
回复

使用道具 举报

梦石
0
星屑
2381
在线时间
169 小时
注册时间
2017-4-25
回帖
185
发表于 2018-5-26 21:35:21 | 显示全部楼层
Mehmet 发表于 2018-2-24 16:12
//-----------------------------------------------------------------------------
// ImageManager
//

怎么用啊?
回复

使用道具 举报

梦石
0
星屑
3930
在线时间
1198 小时
注册时间
2016-8-9
回帖
2355

开拓者

发表于 2018-5-27 14:16:10 | 显示全部楼层
根本不需要子文件夹,因为加了之后即使能够使用插件去解决,但是别的插件需要调用pic文件夹的话,你不能每个插件都去改动,很麻烦的。

我是采用首字母关键字,通过名称来分类的,比如几大类,通过大写字母与数字组合放在名称前即可
酸酸甜甜就④哇噢
回复

使用道具 举报

名侦探小柯

梦石
10
星屑
4425
在线时间
3741 小时
注册时间
2006-9-6
回帖
36596

极短27获奖MZ评测员开拓者贵宾第3届短篇游戏大赛主流游戏组亚军第5届短篇游戏比赛亚军

发表于 2018-5-27 16:53:41 | 显示全部楼层
这个是软件本身的限制,哪怕插件自身支持子文件也没用,你在软件里还是不支持的,除非改软件,所以像LS所说用名字来做规划比较好
不定期回归 ~ 游戏开发之旅
———————————————————————————————
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部