How do I add persist behavior into an array object?

Get help using Construct 2

Post » Wed Feb 26, 2014 2:24 am

@Ashley , there is no way to add persist behavior or no save behavior into an array object or a dictionary object since they are not allowed to have any behavior. (Or do I miss something?)
An array or a dictionary object might need to be persisted when this object is in a persisted container.
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Post » Wed Feb 26, 2014 3:17 am

Aren't the Array and Dictionary objects already persistent?
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Wed Feb 26, 2014 3:39 am

@AllanR

Test but it looks like no persistent for array and dictionary object.

test capx

If array and dictionary object is persisted always, there will have a new problem. How about no-persist array and dictionary objects?
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Post » Wed Feb 26, 2014 4:11 am

@rexrainbow, I made a little test capx before I posted... and it looked like they both were persistent. I am just about to look at yours...

http://www.rieperts.com/games/forum/ArrayPersist.capx
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Wed Feb 26, 2014 4:13 am

@AllanR

In your test case, the array object is "Global" (Global = Yes in properties table), so that it will not be destroy when layout changed.

In my case, the array object is put into a container.
Last edited by rexrainbow on Wed Feb 26, 2014 4:16 am, edited 1 time in total.
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Post » Wed Feb 26, 2014 4:16 am

Yeah, I just saw in yours that the dictionary is destroyed when it is in the containing sprite...
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Wed Feb 26, 2014 4:18 am

@AllanR

Indeed, the dictionary in a container will be destroyed even it is "Global = Yes".
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Post » Wed Feb 26, 2014 4:41 am

@rexrainbow, well, I played around with your version a little more.

I took the dictionary out of the sprite. Made the Sprite global, made the dictionary global, put the dictionary back in the sprite, re-ran the project, and then the dictionary appears to be persistent now...

(setting the dictionary global while it was in the sprite did not work)
B
95
S
33
G
20
Posts: 438
Reputation: 17,640

Post » Wed Feb 26, 2014 5:13 am

@AllanR

Right, sprite global=Yes, will not be destroyed when layout changed, so that it does not need to persist.
B
108
S
26
G
267
Posts: 4,456
Reputation: 149,747

Post » Wed Feb 26, 2014 11:17 am

Persist isn't supported on non-world objects. It's one of many things on the todo list...
Scirra Founder
B
395
S
232
G
88
Posts: 24,368
Reputation: 193,746

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 6 guests