Is there a way to force a tilemap to update?

For developers using the Construct 2 Javascript SDK

Post » Thu Sep 22, 2016 10:05 pm

I have some events that set the tiles in a tilemap, then I have a behavior that modifies the tilemap, however it doesn't appear to have its tilemap_data property updated after the first events set tiles in the map.
Is there a way to force the tilemap_data to be updated before I run the behavior code?
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Thu Sep 22, 2016 10:14 pm

I can't think of anything tilemap does that's not synchronous, other than changing the texture.
If there was, it would most likely happen the next tick.
Image ImageImage
B
169
S
50
G
170
Posts: 8,292
Reputation: 108,728

Post » Thu Sep 22, 2016 10:20 pm

hm.. I just tried adding a Wait 1.0, and it still doesn't update the tilemap_data
My behavior reads the this.inst.tilemap_data
Based on that, it alters it and then returns a jsonString that can then be loaded back into the tilemap.

so, if I edit the tilemap via construct2 events beforehand, the this.inst.tilemap_data is never updated.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949

Post » Thu Sep 22, 2016 10:40 pm

You need to look at what the tilemap plugin does when it modifies the tilemap. It looks like it sets some booleans indicating things need to be updated, then in turn the draw function calls another function that checks the booleans and updates as needed.
B
92
S
32
G
107
Posts: 5,280
Reputation: 69,971

Post » Thu Sep 22, 2016 10:56 pm

Okay,
I changed my behavior to rely on the actual cell/tile data instead of the tilemap_data value.
So now I can retrieve the updated map.
Can't rely on the tilemap_data because that never gets updated after creation.
B
43
S
19
G
65
Posts: 1,105
Reputation: 37,949


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests