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

Using Tiled to define enemy locations


barodapride
 Share

Recommended Posts

it depends on how how like to create your enemies I think. Phaser.Tilemap has a function createFromObjects() that it can make sprites from an object layer defined by name. There are some limitations. Currently, the tilemap loader will only load objects in your object layer that have a "gid" property from Tiled, which it will only get if it is an object with an associated tileset frame (ie the generic object polygons in tiled won't load without some hackery).

 

Then after it makes the generic Sprites it's up to you to make the sprites do things, interact, and do physics.

 

definitely look at the tilemap's createFromObjects() (yourmap.createFromObjects()) function and also the tilemap's object (yourmap.objects) property, which is where createFromObjects() gets its objects from.

 

I like modularizing my Sprites ahead of time, so i had to do a little hackery of the Phaser.Tilemap.prototype to get it to load objects by their names rather than creating generic sprites, but this is my own preference and doesn't mean it's the best way to do it (whatever that means)

Link to comment
Share on other sites

Hi jcs, I cloned your repository (I guess it's called forked? Not sure what the difference is between forked and cloning...). Anyways, I will say I still haven't given this an honest effort yet but I think I will need more help on how I can break off some of your code and use it properly. I would like to understand more completely what I need to do here. Correct me if I'm wrong but all I need to do is get data from a tilemap layer. I'm not sure what functions Phaser has to support this but I definitely have access to the .json map file within javascript correct? If so, I should be able to write my own code to handle the new enemy layer and input those objects into the game. Anyways, I would have thought this would be a simple and straightforward task but it seems to be difficult. What is the point of using Tiled if you cannot define enemies and other dynamic objects within it? I am just looking for an environment where I can create each level of my game completely. Manually adding the enemies/items programatically would take a long time.

Link to comment
Share on other sites

you don't need to fork the repository unless you plan on committing changes back to it, or want to create a completely separate version of your own that you will share with the world. (github uses "forks" to handle accepting and merging changes, which is a bit of a non-standard use of the term). a local clone gets you a copy of the repository - everything you need - on your machine.

 

as 99golems said above, Phaser provides the createFromObjects() function which will let you create basic Sprite objects from an object layer in the Tiled file. Nadion, on the other hand, uses the Tiled file and creates from it objects of classes that are defined in your code or in Nadion and supports some predefined objects like Triggers, Areas, Alarms etc that are useful for defining game logic in Tiled. I created Nadion by pulling common elements out of a game that I'm working on with a non-coder. it lets us define more of the game in Tiled than we would otherwise be able to. there is a complete, working sample in the 'sample' directory.

 

but none of this will keep you from having to write your own code for the sprites and game logic and input handling and a million other things. if you want an environment that lets you operate with little-to-no code, you probably want something like 'game maker' as opposed to a game engine like Phaser.

 

you can, of course, also easily write code to load the objects from the json yourself. createFromObjects() shows you one way, and the Nadion source shows another - easy enough to write another one yourself! :)

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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