Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

Parameters from Tiled Json


Climbus
 Share

Recommended Posts

Hi all

 

I'm using Phaser with json maps created by Tiled.

 

In Phaser docs i found info that i can use parameters: http://docs.phaser.io/Phaser.Tilemap.html#createFromObjects. 

 

I tested it and it is not working corectly with maps generated in Tiled. I attached exeample.

 

Tiled puts all parameters values in quotes: "body.velocity.x":"10". In that case object goes fast to maxVelocity.

When i remove quotes manualy, object is moving with given velocity.

 

In my example you can comment line 7 and uncomment line 8 in main.js file to check two cases.

 

Is this Phaser bug or i'm doing something worong?

 

Climbus

TestCreateFromObject.zip

Link to comment
Share on other sites

I think Tiled's output is interpreted as a string, so you might have luck with trying parseInt()?

 

I'm using Phaser internal function so i cant add parseInt in code responsible for setting parameters.

 

I think that code dont't evaluate this string so i cant put "parseInt(10)" to Tiled.

Link to comment
Share on other sites

Hmm good point. I'm not sure there is an easy fix for this. If I parseInt every value then it will break string / object based properties. If I leave it as is, some properties will convert from strings to integers fine, and others won't. I'm not sure there is an easy solution for this.

Link to comment
Share on other sites

Hmm good point. I'm not sure there is an easy fix for this. If I parseInt every value then it will break string / object based properties. If I leave it as is, some properties will convert from strings to integers fine, and others won't. I'm not sure there is an easy solution for this.

 

Maybe Point object can have setter for x and y values. I dont know is it posible in JS.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...