hi guy, i have a error when i try inject a JSON in pixi loader
i get my JSON files path from nwJS with this following code.
it give me ex: "C:\Users\jonle\Documents\Games\A NEW FANTASTIQUE TIME TOME1\SSA\Decoration\tree\tree1\tree1.json"
how i can normalize path for use in pixiLoader without use regex ?
i take a look with command path.normalize(path)
https://nodejs.org/docs/latest/api/path.html#path_path_resolve_paths
but it not work.
pixi loader have a native way to take win32 path ?
Or do you have suggest for me (without Regex)
JSON_LIBRARY give me error because path are in win32
i get my JSON files path from nwJS with this following code.
it give me ex: "C:\Users\jonle\Documents\Games\A NEW FANTASTIQUE TIME TOME1\SSA\Decoration\tree\tree1\tree1.json"
how i can normalize path for use in pixiLoader without use regex ?
i take a look with command path.normalize(path)
https://nodejs.org/docs/latest/api/path.html#path_path_resolve_paths
but it not work.
pixi loader have a native way to take win32 path ?
Or do you have suggest for me (without Regex)
PHP:
(function(){
var fs = require("fs");
var path = require("path");
var gameDir = path.dirname(process.mainModule.filename);
path.sep = '/'
var walkFolder = function(dir, done) {
var results = [];
fs.readdir(dir, function(err, list) {
if (err) return done(err);
var pending = list.length;
if (!pending) return done(null, results);
list.forEach(function(file) {
file = path.resolve(dir, file);
fs.stat(file, function(err, stat) {
if (stat && stat.isDirectory()) {
walkFolder(file, function(err, res) {
results = results.concat(res);
if (!--pending) done(null, results);
});
} else {
(file.indexOf('.json')>0) && results.push(file); // push only .JSON ext
if (!--pending) done(null, results);
}
});
});
});
};
walkFolder(gameDir+'/SSA', function(err, results) {
if (err) throw err;
pixiPME.JSON_LIBRARY = results;
pixiPME.nwJSLoadComplette = true; pixiPME.canStartPixiLoad();
});
})();
////////////////////////////////////////////////////////////////////////////////////////////////
// READY TO INITIALISE LOADER FOR ALL DATA JSON LIBRARY
_pixiPME.prototype.initialise = function() {
// load all json libs
PIXI.loader.add(this.JSON_LIBRARY[0])//GET ERROR HERE BECAUSE PATH ARE IN WIN32 FORMAT
console.log('this.JSON_LIBRARY[0]: ', this.JSON_LIBRARY[0]);
for(var f = 0; f<this.JSON_LIBRARY.length;f++){
//PIXI.loader.add(this.JSON_LIBRARY[f]); // ADD JSON RESSOURCE
break
}
JSON_LIBRARY give me error because path are in win32