Reset layout and instances?

Get help using Construct 2

Post » Mon Jan 16, 2012 10:36 am

My layout loop looks like this:
Intro->Main game->High Score list->back to Intro

The Main game layout is a huge level with sprite instances created inside the editor. The first time through everything works as expected. But once I reach the High score and then return for a second playthrough some of the sprite instances have disappeared.

Is there a way to do a clean reset of the layout so it's exactly the same as it was the first time through ?

I am calling System.ResetGlobalVariables after the High Score layout but still occasionally some of those original sprites don't show up.
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Mon Jan 16, 2012 11:09 am

Hmmm can't give a usefull answer, it's probably due to some ways you create your sprite. Or some ways you destroy them. Can't say much with only what you said.
Might be a good idea to post the capx. Even screenshots might not be enough.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Jan 16, 2012 9:12 pm

I am doing weird things with my sprites during gameplay, but my question is this:
Once the level is complete, how do I completely reset a layout to its original state?
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Mon Jan 16, 2012 9:24 pm

System: Reset global variables
Objects: Put back instances variables to their default value (you have to handle it yourself)
System: Go to layout "current layout"

But as Yann said:
It's probably due to some ways you create your sprite. Or some ways you destroy them.
Can't say much with only what you said. Might be a good idea to post the capx.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Mon Jan 16, 2012 9:29 pm

If you don't use global objects, just reseting global variables should be enough.
If you use global objects it's a bit more complicated.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Mon Jan 16, 2012 10:10 pm

@Yann:
No global objects, and I am calling "reset global variables" after the level is done.

@Kyatric:
Can't post the capx due to copyright issues (artwork is done by client, not by me)..sorry. Here's a description of what's going on:
the game is basically a shoot'em up like the Space Blaster example. In the editor I have placed about 70 enemy sprites with some instance variables like health, point value, etc.
As the player scrolls along, the enemies come into view. Once they do I start their custom movement and the player tries to shoot them. Once the enemy health reaches 0 or when it leaves the layout I destroy the enemy.

Eventually I do a goto Layout ("Game Over") followed by resetting global vars and then return to the same level, i.e. goto Layout("Main"). At this point MOST of the enemies seem to have been reset. But some no longer show up.
B
12
S
3
G
3
Posts: 73
Reputation: 2,647

Post » Mon Jan 16, 2012 10:25 pm

[QUOTE=Cross_]@Kyatric:
Can't post the capx due to copyright issues (artwork is done by client, not by me)..sorry. [/QUOTE]

In that case, just reproduce in a new capx with placeholder graphics. (or modify the graphics in the current project and save as a new capx)

I even prefer placeholders, it's quicker to download.

Also when you say "I have placed about 70 enemy sprites" are those different objects or instances ?

Once again, without the capx it's near to impossible to say exactly what's going wrong.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Thu Sep 27, 2012 9:16 pm

Ive been having the same problem. Im using a global variable to set the score and to be able to paste it in another layout (score table). But when I use "reset global variables", nothing happens. And when I jump from menu layouts to gameplay layouts all events are not reset.
Should I reset manually the global variables, like "set value = 0" or something like that?.
Thanks.
B
11
S
1
G
2
Posts: 57
Reputation: 1,690


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests