The 'Real World Examples' Thread

Post your own tutorials, guides and demos.

Post » Mon Mar 02, 2009 2:11 pm

Hey guys,

Thought a thread like this would make sense to showcase solutions for problems that most likely all Construct users will go through at one point or another.

1.) Pause Function:

Let's start with something simple, a 'Pause' function for the game, which - if the 'Pause' variable is at 1 will freeze the game, show a 'Pause' image and pause the music. If it's at 0, it'll unfreeze the game, hide the 'Pause' image and resume the music. Pretty simple:



Then, in your controls event sheet, you'd simply set up an event that'd drive the 'Pause' global variable like this:



Et voila.
B
6
S
2
G
3
Posts: 520
Reputation: 2,690

Post » Wed Mar 04, 2009 8:42 pm

Pause menu

Groups can be useful with this kind of problem. If you group all code in groups, you can disable one set of groups and enable the other set when pause button is pressed.

The only problem with this is when you have to stop behaviors. Like objects which use platform, sine, physics behaviors. You can't access objects via behavior (at least I am not aware how). The solution would be to create one family per behavior, add family to each object using corresponding behavior and just disable these "behavior" families.

Unfortunately, families seem to be broken in current version. To be accurate, the game results with bug when I use more than one family per object.
B
2
G
3
Posts: 75
Reputation: 1,000

Post » Wed Mar 04, 2009 8:50 pm

Just set timescale to 0 to pause every behavior.

Also for the second screenshot at the top, you could set the global variable to '1 - global('Pause')' instead of the else event.
B
3
S
2
G
5
Posts: 1,777
Reputation: 5,529

Post » Tue Mar 10, 2009 7:59 pm

In order to make the thread a bit more useful, let's change the rules a bit:

You can post:

1) Requests
2) Examples

Using these templates:

For Requests:
Objective: What are you trying to achieve? Explain in simple steps that are easy to understand.
Info: You could give examples like 'Look at this Youtube video, it should work like this!' - Just so people know exactly what you want to achieve.
Resource: Post the .cap files of what you've already tried that didn't work.

///

For Examples:

Objective: What were you trying to achieve? What does the shown setup do?
Info: "I used Containers in this case, because..." , "I thought there'd be a simpler way to do this, but I had to..." , "My idea was that I could just reuse...", etc. - Tell us how you got to your solution and what the whole deal is all about.
Resource: Post a .cap file or a screenshot of your setup.

-------------------------


Okay, my turn:

I'll start with a Request:

Objective: I'm trying to set-up a smart dialogue system that'd work like in most other adventures or RPGs. If you overlap a sprite that you can talk to and you hit the action key, a dialogue box will be made visible and the platformer behavior will be frozen temporarily.

The dialogueBox is just a textobject that's linked to a timeline object, just so I can create multi-page dialogues. Then, I hit the action key again to advance through the dialogue. Once I'm through the whole timeline period, the dialogueBox will be hidden, the platformer behavior will be set to active again and I can keep going.

Info: Pretty standard dialogue behavior, should be understandable without extra info.

Resource: I cobbled together a .cap file before and sent it to David. David corrected it, but we're still not quite there:

http://www.thomasmahler.com/files/const ... _david.cap
B
6
S
2
G
3
Posts: 520
Reputation: 2,690

Post » Sun Mar 15, 2009 3:13 pm

[quote="Rich":2ejxo83p]Just set timescale to 0 to pause every behavior.

Also for the second screenshot at the top, you could set the global variable to '1 - global('Pause')' instead of the else event.[/quote:2ejxo83p]

With timescale to 0 objects still check collisions and other stuff, so you can't really make a pause in certain games.

Just create a variable : "Paused".

Before every game condition check if "Paused" is 0.
B
2
S
2
G
5
Posts: 512
Reputation: 2,674

Post » Sun Mar 15, 2009 3:19 pm

[quote="SuperV":97bfvpsk]Before every game condition check if "Paused" is 0.[/quote:97bfvpsk]
If you really need to do that, you could just enable/disable a group of events, or put them all in a subevent to a 'paused is 0' event. You definitely don't need to repeat the condition over and over.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,498

Post » Sun Mar 15, 2009 3:26 pm

You can also pause by using a modal layout object.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Sun Mar 15, 2009 4:38 pm

[quote="Arima":2fdj1tuy]You can also pause by using a modal layout object.[/quote:2fdj1tuy]

What is this? I've seen the term used before, but I have absolutely no clue what it means :(

I'm probably really stupid for not knowing, huh?
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Mar 15, 2009 5:00 pm

Makine a layout object modal means it pauses everything in the layout below it.

Well, almost everything - there's a bug at the moment that still runs some mouseclick events, but it's not supposed to.
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397

Post » Sun Mar 15, 2009 5:01 pm

[quote="deadeye":naa7owr1][quote="Arima":naa7owr1]You can also pause by using a modal layout object.[/quote:naa7owr1]

What is this? I've seen the term used before, but I have absolutely no clue what it means :(

I'm probably really stupid for not knowing, huh?[/quote:naa7owr1]

No. Just something you probably never found a use for. The layout object (which allows layouts to be show in other layouts ([size=50:naa7owr1]yo dawg we put a layout in your layout so you can view layouts while you view layouts![/size:naa7owr1])).

The layout object has a few modes. One of them is modal.

Edit:

ARRGGH beaten to the punch.
B
2
S
2
G
4
Posts: 136
Reputation: 1,722

Next

Return to Your tutorials & example files

Who is online

Users browsing this forum: No registered users and 2 guests