How do I restore destroyed objects? (CAPX Included)

Get help using Construct 2

Post » Tue Sep 27, 2016 10:20 pm

Hey guys! I'm working on a project and i need some help please.. :roll:

I use touch to destroy 1 object each time. Now i want, when i press "restore" button to restore the latest object.
Is this too difficult??? :?:

Here is the capx, hope to find a solution someone:
https://www.dropbox.com/s/urlq58ujldev0 ... jects.capx

Thanks again guys!!! ;)
B
54
S
33
G
15
Posts: 230
Reputation: 12,987

Post » Tue Sep 27, 2016 10:34 pm

I assume that when an instance is destroyed there is no information kept on it's last location and such. But you have several options I can think of of the top of my head:

Instead of destroying the instance move it off screen or turn it invisible
Respawn an instance of the object
If the instance won't always be in the same location then you could use the 'on instance destroyed' to store location or other information in global variables or array.
If all objects need to get restored you can simply use 'restart layout'

In short I don't believe there is any event that you can set this up in one step but you have plenty of tools at your disposal to achieve what you desire.
ImageImageImage
B
43
S
26
G
11
Posts: 516
Reputation: 10,473

Post » Wed Sep 28, 2016 2:40 am

I though there is a way to read the object, a tip, you know. In my example i need to read with some way, what frame was, what position maybe and after destroy to create a new object.
I don't need to restore exactly the same object, just a clone but with same details.

Example: Last object was a red item with X: 100 and Y: 200. So i need to restore the same object not just the sprite again with a random frame (more details inside capx).

Another example is to have different sprites, not 1 sprite with different frames. So in this way to restore exactly the sprites.

In words it's more easy, i know.. :)

I need to restore each object not everything, so i don' need something like "restart layout".
Maybe "invisible" it's a good option.. Thanks for your answer! ; -)
B
54
S
33
G
15
Posts: 230
Reputation: 12,987

Post » Wed Sep 28, 2016 4:14 am

Yeah, in short, I don't think destroying it is the smart choice if you want to retain that much information about it
ImageImageImage
B
43
S
26
G
11
Posts: 516
Reputation: 10,473

Post » Wed Sep 28, 2016 10:43 am

Ok, thanks again! ; -)
B
54
S
33
G
15
Posts: 230
Reputation: 12,987


Return to How do I....?

Who is online

Users browsing this forum: Psynaptik and 64 guests