Jump to content

Callback in Tilemap.createFromObjects


seiyria
 Share

Recommended Posts

Is there a way to pass a callback to this, for when all of the Tiled attributes I set have been loaded onto the object? For example, suppose I set:

 

auto: true

distance: 10

 

on an object, and I want to make use of these in my objects custom constructor that I pass in? Here is my call:

    @map.createFromObjects 'PlatformLayer', @gids.PLATFORM_HORIZONTAL, 'platforms', 1, true, false, undefined, HorizontalPlatform

I'd like it to be:

    @map.createFromObjects 'PlatformLayer', @gids.PLATFORM_HORIZONTAL, 'platforms', 1, true, false, undefined, HorizontalPlatform, 'isReady'

And then, on HorizontalPlatform, I would have an isReady function that could be called when all of the Tiled parameters have been loaded so I don't have to do any weird stuff like setTimeout while waiting for it to finish loading.

Link to comment
Share on other sites

jdowell pointed out to me that it is possible to handle this in such a fashion:

objectGroup = @game.add.group()map.createFromObjects "PlatformLayer", gids.PLATFORM_HORIZONTAL, "platforms", 1, true, false, objectGroup, HorizontalPlatformobjectGroup.callAll "isReady()"

Not ideal for every use-case, but it should suffice for most.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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