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
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

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
172
S
50
G
182
Posts: 8,439
Reputation: 115,097

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
48
S
23
G
66
Posts: 1,144
Reputation: 39,059

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
94
S
33
G
118
Posts: 5,393
Reputation: 75,847

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
48
S
23
G
66
Posts: 1,144
Reputation: 39,059


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests