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
49
S
23
G
66
Posts: 1,151
Reputation: 39,103

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
173
S
50
G
194
Posts: 8,569
Reputation: 121,374

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
49
S
23
G
66
Posts: 1,151
Reputation: 39,103

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
95
S
33
G
128
Posts: 5,491
Reputation: 81,570

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
49
S
23
G
66
Posts: 1,151
Reputation: 39,103


Return to Javascript SDK

Who is online

Users browsing this forum: No registered users and 0 guests