How do I Make a Functioning Game Over Screen?

Get help using Construct 2

Post » Thu Jan 12, 2017 9:06 pm

Hello, everyone! I'm having an issue here that I'm breaking my head over, and what I would like is so simple. I'm trying to make a game over screen- and so far, I have the design and a working 30-second countdown.

What I'm looking for is a way so that when the player presses the space bar, the game takes you back to the last layout you were in, at the very beginning. The 'previous layout' function works with the specific and manual ordering of the layouts in the Projects bar, which is not what I want. I've also attempted the 'Global Variable: Source Layout=LayoutName' tactic, to no avail. Does anyone have a clue as to how I can go about this? Any help would be greatly appreciated!! Thanks in advance. :mrgreen:
B
13
S
2
Posts: 11
Reputation: 647

Post » Fri Jan 13, 2017 1:32 am

Firstly, I'm assuming your game over screen is a separate layout. You probably don't need to do this - just make it a layer that appears on top of your current layout. Then all you need to do is system-restart layout.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083

Post » Fri Jan 13, 2017 1:33 pm

oosyrag wrote:Firstly, I'm assuming your game over screen is a separate layout. You probably don't need to do this - just make it a layer that appears on top of your current layout. Then all you need to do is system-restart layout.


Alright, so I managed to convert the separate layout into a global layer which works just fine. So I thank you for that tip!! But now I've run into a new issue: No matter what I do, I can't get the 30 second countdown to function, nor the music that is supposed to play when the layer is visible.

I can't post a screenshot of my programming because I'm on my phone right now, but I have it as this:

[ Layer 'GAMEOVERSCREEN' is visible ]:
>System; set game over_countdown to 30
>Audio; stop all
>System; wait 0.1 seconds
>Audio; play GAMEOVER looping
>Text; Game over_Countdown: set visible

[ Subevent; Every tick ]:

>Text; set text to Game over_Countdown

[ Subevent; Every 1.0 seconds ]:

>System; subtract 1 from Game over_Countdown

[ Subevent; Game over_Countdown = 0 ]:

>System; Go to TITLE

[ Subevent; Keyboard; On Space Pressed ]
[ Condition; Game over_Countdown > 0 ]:

> Restart layout

...Any ideas?? :?
B
13
S
2
Posts: 11
Reputation: 647

Post » Fri Jan 13, 2017 9:48 pm

I think your main event "[ Layer 'GAMEOVERSCREEN' is visible ]:" is running every tick (while your game over screen is visible). So every tick it is stopping the audio, and setting the countdown timer back to 30.

The single run actions associated with your game over screen should be in the event that triggers the game over to begin with (what event causes your game over layer to become visible?). In that same event, you should run all the actions that you want only to trigger once.

A function can be useful in scenarios where you have many separate conditions that trigger game over, so you don't have to copy the same actions over and over again.
Mistakes were made.
B
54
S
28
G
115
Posts: 1,705
Reputation: 65,083


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests