Is it possible to draw a line like a primitive geometry on an object layer?

I want to draw arrows in Tiled.

But I can not find any tool to draw arrows. Is it possible?

If it is interesting:

I use LibGDX to create my game and I write the game logic directly in Tiled. It means - I create texts with script data on an objects layer. When the map is loaded in my game engine - these text fields will be transferred using Java-Serialization in Java-objects to control the game process. It looks like visual programming (like Blueprints in Unreal Engine or Nodes in Blender).

But when I want to make that a first script must activate a second script, I create a third script. I want to draw an arrow which will point from the script-activator on the target script. It will replace the intermediate script. I will determine from the code the source point and the target point and find the texts which are over these points.

It can be not so simple to understand but maybe you can determine the problem on the screenshot (see the last part of the class name for every script do determine the purpose) .

Are your scripts Text Objects, is that why they’re visible on your map? If so, you can use Object Reference properties on them to refer to another script Object, and Tiled will render those references as dotted lines with arrows (if you have View > Show Object References enabled). The upside of this is the arrows will point to the referenced object even if you change its position in the map, and you can use those same object reference properties to guide your scripts’ execution in your game.

If Object References won’t do and you need to manually draw arrows, you can create lines with the Insert Polygon tool. A polygon that hasn’t been closed is a polyline. A polyline with only two nodes is a straight line segment. You could get fancy with this and draw arrowheads too, but it’ll probably be easier to edit the line if you keep it a simple line segment.

@eishiya

Thanks for the advice. The first idea is better - it works as I wanted. Every script is a separate text with its own ID. Can you advice also what should I do if I need that one script activates more scripts? My idea is to add many field with same prefix name, for example: “NEXT_1”, “NEXT_2”, “NEXT_3” and so on. But maybe there are an another way?

The second question - how should I read this field? I can receive an array with properties but what should I do after that?

That all depends on how you want to do things. What would be intuitive for you when authoring maps in Tiled, and what would be easy for you to parse when loading the files in-engine?

  • You can create a List of properties rather than 3 independent properties, for one thing.
  • You should probably also think about conditionals - would you want the name of the variable that determines whether to run a script to be in the reference property’s name (e.g. runNextIf_MyVar), or would you want some parallel properties that have the variable names as their values?
  • You could have the reference property names serve as identifiers, and refer to those in the scripts themselves, e.g. a script could say if(some condition) runScript(coolerScript) and “coolerScript” would be one of your script reference properties. This is the option I’d probably go with personally, if I wasn’t doing scripts in a completely different way.

I can not understand how to create an array – this is the list of all possible property types.

I don’t understand why I should think about the conditions – some of my scripts are already conditions. The arrows are only the comfortable way to make the relationship like: “parent activates child”. For example: I will not detailed explain what every script does but it is understandable from the script names like in the next cha in:

ReleaseScriptObjectDestructionListener (ID1, parameter: barre l ID)

ReleaseScriptEntityInZoneListener (ID2, parameter: player ID, zon e ID3)

ReleaseScriptLogicalAnd (params: ID1 a nd ID2)

/*These upper script points to the next two sc ripts */

ReleaseScriptSoundPlayer (parameter: sound FileName)

ReleaseScriptObjectTransfer (parameter: enemy ID, zon e ID3)

This chain means:

If the barrel with ID==1 will be destroyed and the player will be in zone ID3 the sound with name “soundFileName” will be played (demon scream) and the enemy (smoke gin) will be transferre d in zone ID3

As the result: the player attacks the barrel and the gin appears in the place where the barrel was and sound plays.

Lists are available as of Tiled 1.12, perhaps you’re using an older version?

If you don’t need conditionals, then you don’t need conditionals xP That’s why I said how you set up the properties depends on how you want to do things.