dist/melonjs.js
function setTMXValue(name, type, value) {
         var match;

         if (typeof value !== "string") {
           // Value is already normalized (e.g. with JSON maps)
           return value;
         }

         switch (type) {
           case "int":
           case "float":
             value = Number(value);
             break;

           case "bool":
             value = value === "true";
             break;

           default:
             // try to parse it anyway
             if (!value || me.utils.string.isBoolean(value)) {
               // if value not defined or boolean
               value = value ? value === "true" : true;
             } else if (me.utils.string.isNumeric(value)) {
               // check if numeric
               value = Number(value);
             } else if (value.search(/^json:/i) === 0) {
               // try to parse it
               match = value.split(/^json:/i)[1];

               try {
                 value = JSON.parse(match);
               } catch (e) {
                 throw new Error("Unable to parse JSON: " + match);
               }
             } else if (value.search(/^eval:/i) === 0) {
               // try to evaluate it
               match = value.split(/^eval:/i)[1];

               try {
                 // eslint-disable-next-line
                 value = eval(match);
               } catch (e) {
                 throw new Error("Unable to evaluate: " + match);
               }
             } else if ((match = value.match(/^#([\da-fA-F])([\da-fA-F]{3})$/)) || (match = value.match(/^#([\da-fA-F]{2})([\da-fA-F]{6})$/))) {
               value = "#" + match[2] + match[1];
             } // normalize values


             if (name.search(/^(ratio|anchorPoint)$/) === 0) {
               // convert number to vector
               if (typeof value === "number") {
                 value = {
                   "x": value,
                   "y": value
                 };
               }
             }

         } // return the interpreted value


         return value;
       }
function setTMXValue(name, type, value) {
         var match;

         if (typeof value !== "string") {
           // Value is already normalized (e.g. with JSON maps)
           return value;
         }

         switch (type) {
           case "int":
           case "float":
             value = Number(value);
             break;

           case "bool":
             value = value === "true";
             break;

           default:
             // try to parse it anyway
             if (!value || me.utils.string.isBoolean(value)) {
               // if value not defined or boolean
               value = value ? value === "true" : true;
             } else if (me.utils.string.isNumeric(value)) {
               // check if numeric
               value = Number(value);
             } else if (value.search(/^json:/i) === 0) {
               // try to parse it
               match = value.split(/^json:/i)[1];

               try {
                 value = JSON.parse(match);
               } catch (e) {
                 throw new Error("Unable to parse JSON: " + match);
               }
             } else if (value.search(/^eval:/i) === 0) {
               // try to evaluate it
               match = value.split(/^eval:/i)[1];

               try {
                 // eslint-disable-next-line
                 value = eval(match);
               } catch (e) {
                 throw new Error("Unable to evaluate: " + match);
               }
             } else if ((match = value.match(/^#([\da-fA-F])([\da-fA-F]{3})$/)) || (match = value.match(/^#([\da-fA-F]{2})([\da-fA-F]{6})$/))) {
               value = "#" + match[2] + match[1];
             } // normalize values


             if (name.search(/^(ratio|anchorPoint)$/) === 0) {
               // convert number to vector
               if (typeof value === "number") {
                 value = {
                   "x": value,
                   "y": value
                 };
               }
             }

         } // return the interpreted value


         return value;
       }
function setTMXValue ( name , type , value ) { var match ; if ( typeof value !== "string" ) { // Value is already normalized (e.g. with JSON maps) return value ; } switch ( type ) { case "int" : case "float" : value = Number ( value ) ; break ; case "bool" : value = value === "true" ; break ; default : // try to parse it anyway if ( ! value || me . utils . string . isBoolean ( value ) ) { // if value not defined or boolean value = value ? value === "true" : true ; } else if ( me . utils . string . isNumeric ( value ) ) { // check if numeric value = Number ( value ) ; } else if ( value . search ( / ^json: / i ) === 0 ) { // try to parse it match = value . split ( / ^json: / i ) [ 1 ] ; try { value = JSON . parse ( match ) ; } catch ( e ) { throw new Error ( "Unable to parse JSON: " + match ) ; } } else if ( value . search ( / ^eval: / i ) === 0 ) { // try to evaluate it match = value . split ( / ^eval: / i ) [ 1 ] ; try { // eslint-disable-next-line value = eval ( match ) ; } catch ( e ) { throw new Error ( "Unable to evaluate: " + match ) ; } } else if ( ( match = value . match ( / ^#([\da-fA-F])([\da-fA-F]{3})$ / ) ) || ( match = value . match ( / ^#([\da-fA-F]{2})([\da-fA-F]{6})$ / ) ) ) { value = "#" + match [ 2 ] + match [ 1 ] ; } // normalize values if ( name . search ( / ^(ratio|anchorPoint)$ / ) === 0 ) { // convert number to vector if ( typeof value === "number" ) { value = { "x" : value , "y" : value } ; } } } // return the interpreted value return value ; }
set and interpret a TMX property value
@ignore
set and interpret a TMX property value