How do I destroy obiect permamently

Just started using Construct 2? Post your questions here

Post » Sun May 22, 2016 2:22 pm

When i have few sprites on layout, when i click on sprite > sprite destroy
When i close game and run again this destroyed sprites should be destroyed forever
how do that thing?
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Sun May 22, 2016 5:40 pm

You need to save the state of your game (system > save/load)
https://www.scirra.com/tutorials/search ... %20storage

or work with local storage
https://www.scirra.com/tutorials/search ... %20storage

it depends on the kind of game - save/load is easy to implement and local storage gives you the freedom to control what you want to save.

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Sun May 22, 2016 8:45 pm

@fm4fanAT
thanks

even if have one sprite copied multiple times in layout this will be work only for one destroyed sprite?
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Mon May 23, 2016 11:32 am

The save/load captures the exact moment in time - so yes, just save the state off your game after you destroy the object.

The local storage is another thing. Here you have to declare everything yourself what you want to save.

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Tue May 24, 2016 3:52 am

@fm4fanAT i read about local storage, i could save numbers, position of object but how save in local storage object if is or is not on layout?
Existence of sprite is not a number so how do i save this on local storage?
Can you give me expression or better capx example?
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Tue May 24, 2016 9:03 am

@IGDev
It depends on your game - so here just some thoughts

You could store a dead/alive value and the UID in an array.
Or make some instance variable of your enemies (like dead/alive and xEnemy number) - and store this in an array
Or when you create the enemy you store the UID in the arrays and when destroyed delete it out of the array.
if you provide a capx example I would have a better clue.

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Tue May 24, 2016 10:53 am

@fm4fanAT so create one sprite and copy few times on layout.
On ame click on sprite > destroy
now log out from game and run again
destroyed sprites should not revive on start of layout
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Tue May 24, 2016 11:28 am

Here is an example of what I meant.
It still needs some work till it is working
but if you make a local storage it would work with 1 object. If you write it into an array and check if UID is in array it should work.

Image

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Post » Tue May 24, 2016 2:16 pm

@fm4fanAT this should work wit all objects so array is needed.
I should wait for your code update?
B
25
S
8
Posts: 219
Reputation: 2,181

Post » Tue May 24, 2016 2:41 pm

Sorry, didn't plan to make the whole capx

For arrays the best tutorial to start is https://www.scirra.com/tutorials/307/ar ... ers/page-1

  • System > On start of layout | system > load game from slot "brain"
  • System > On load failed | system > scroll to obj_Forum
B
17
S
8
G
5
Posts: 340
Reputation: 4,707

Next

Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 2 guests