Pausing and Unpausing and also Menu System

Get help using Construct 2

Post » Fri Jun 29, 2012 7:41 pm

Hi,

I'm having trouble making somewhat sophisticated pausing and menu systems.
I made the post below, so you can know what the project is that I'm working on...

http://www.scirra.com/forum/interactive-comic-book-how-many-people-would-buy_topic49895.html?KW=

(first of all you can access the hud at the top by clicking the top black bar or you can hover over the top corners to bring up either the pause or menu buttons)

As you can see from my project capx (below), when you click the pause button (top right), everything pauses as it should. However, if you leave it paused you notice that it still goes to the next layout anyway. I know this is because the system is still running and only the object timescales are paused, but I don't know how to fix it. If I use the system timescale = 0 then I will run into problems with animations of the play, pause, and menu (top left) buttons, probably some other problems way down the road as I add more features.

As you can see I have timescale instance variables for each item in layout 1 (I haven't added them to the other layouts yet because what's the point if it doesn't work). When layout 1 starts, only the zooming in part has a timescale instance variable of 1, everything else starts at 0. When it is time for things to fade in and out, those instance variables then become 1. This (and the lovely family behaviors system) helps everything from popping up at once right at the start. Any ideas how to also pause the transition to the next layout without actually pausing the whole system??

Next problem...

As you can see I've begun the process developing a pretty good menu system (yes, the layout is empty but that's the easy part; there will be some stats and whatnot). You click on the button in the top left, which brings up the menu layout. However, I can't find any function anywhere in the program that returns you to the previous layout. Let's say you're on layout 2...you go to the menu, then exit the menu. Where do you go? If I program the menu event sheet to go to layout 2, then it goes to layout 2 everytime, regardless of which layout you were on. When I did a search for this problem on scirra, I found a post where it mentions that you actually CAN go to a previous layout, but it's only on contruct classic. Why isn't this feature on construct 2? Any ideas on how to fix this one, or am I going to have to put all the menu items on every single layout of the comic (there will probably be something like 75-100 layouts when the whole thing is finished).

thanks.

http://philipcomposer.com/comic/unnamed.capx
B
14
S
5
G
4
Posts: 121
Reputation: 3,938

Post » Fri Jun 29, 2012 7:49 pm

First problem: I would try using "System -> Set object timescale" on the objects you don't want to pause.

Second problem: When you go to the menu layout, save the current layout's name to a global text variable. Then, when you resume game, you can use "System -> Go to layout (by name)" and input the variable name.

I kind of skimmed through your post, so tell me if it's not what you're looking for. Nimtrix2012-06-29 19:50:00
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jun 29, 2012 8:02 pm

The thing is, I want to pause everything, including the automatic tendency for the system to switch layouts. See, the program is still ticking even though all the objects are paused, thus time still runs. Is there a way to maybe turn the "go to layout" function as a global variable that I can switch on and off (this is inspired by your solution to the menu problem)?

I will try the menu fix and let you know.
B
14
S
5
G
4
Posts: 121
Reputation: 3,938

Post » Fri Jun 29, 2012 8:09 pm

I can't open your .capx since it uses 3rd party plugins.

So this layout change happens when a certain amount of time has gone by?
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jun 29, 2012 8:25 pm

My bad. Here is the capx without the 3rd party plugins. I use Rex's Touchmouse plugin. Very useful for easy testing on my android devices.

This has mouse only...

http://philipcomposer.com/comic/unnamed.capx
B
14
S
5
G
4
Posts: 121
Reputation: 3,938

Post » Fri Jun 29, 2012 8:28 pm

Hmm, still says it uses TouchMouse.
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jun 29, 2012 8:34 pm

oops, forgot to delete the touchmouse instance. should work now...

http://philipcomposer.com/comic/unnamed.capx

I'm such a noob...
B
14
S
5
G
4
Posts: 121
Reputation: 3,938

Post » Fri Jun 29, 2012 9:17 pm

I'm still not getting the whole menu global text variable thing. It's a little too complicated for me to even explain. Here's the updated capx. You can go to the menu event sheet to see what I changed.

http://philipcomposer.com/comic/unnamed.capx.

Thanks.
B
14
S
5
G
4
Posts: 121
Reputation: 3,938

Post » Fri Jun 29, 2012 9:29 pm

I was already working on the .capx so didn't get a chance to see your updated file. I think I solved most of your problems, but tell me if I broke something in the process.

WayoftheSax_Edited.capx (r97)

I went with a different approach for both the problems, I used a number variable "currentLevel" to keep track of levels, adding to the variable every time the level is changed.

I also added another variable to trigger a level change. With the "changeLevel" variable, you can do a check if the game is paused every time your layout is about to change.

The layout will restart when you enter/exit the menu, I don't know how to fix that other than not using a different layout for the menu. But at least it should return to the "currentLevel" layout now.

Btw, it's a bit difficult to navigate through your project, you should get used to adding comments (Press Q or RClick) and maybe use some groups.Nimtrix2012-06-29 21:41:44
B
27
S
8
G
8
Posts: 903
Reputation: 8,452

Post » Fri Jun 29, 2012 9:49 pm

Thanks, you fixed the problems, but you did indeed break a couple of things. When pressing pause, the current caption now continues its timescale and thus fades out. Also, when returning to the current layout, the black bar at the top is no longer at the top of the layer.

I'll try to fix these, then let you know. Otherwise, thanks a bunch!
B
14
S
5
G
4
Posts: 121
Reputation: 3,938

Next

Return to How do I....?

Who is online

Users browsing this forum: Lof, YoHoho and 21 guests