Global object instance increases on layout change?

Get help using Construct 2

Post » Tue Mar 17, 2015 7:50 am

Hey all,

I have been trying to work on a global UI HUD that is visible on the main game screen, but disappears when transitioning to layout 2. I feel I have successfully been able to accomplish this, however, I have found that my global objects create another copy of themselves in the exact place as the original when I transition from layout 2 back to layout 1.

This increase in object count seems to only occur per the total number of layouts I transition to from the original. For example, if I had 3 layouts where I transition from layout1>layout2>layout3>layout1, there would be 3 sets of the original global objects.

I did some research looking at tutorials and searching the forums, but other than this example, https://www.scirra.com/tutorials/594/building-a-global-user-interface-ui/page-2 , I have not found much that would help with my situation.

It should be noted that my methods do vary slightly from the link above (in that project the UI page is revisited prior to restarting the main game, however, in my case, I would just like to transition from layout1 to layout2 and back akin to an equipment screen).

I have attached a capx example for those of you that are interested in taking a look.

Any guidance would be greatly appreciated.
You do not have the required permissions to view the files attached to this post.
B
5
S
1
Posts: 4
Reputation: 283

Post » Tue Mar 17, 2015 7:55 am

I use a startup layout to create my global objects. This layout only ever gets run once at the start of the game. Maybe that's something you could try?
B
32
S
14
G
5
Posts: 499
Reputation: 6,656

Post » Tue Mar 17, 2015 8:37 am

I'm not really sure what you mean, in my capex I am not creating any UI objects via create or spawn, any object creation is just from manual placement in the UI layout.
B
5
S
1
Posts: 4
Reputation: 283

Post » Tue Mar 17, 2015 11:06 am

A global object does not get destroyed when you move to another layout.
Who dares wins
B
56
S
15
G
17
Posts: 1,843
Reputation: 17,287

Post » Tue Mar 17, 2015 12:37 pm

lennaert wrote:A global object does not get destroyed when you move to another layout.


Hi Lennaert,

Thanks for the reply. I understand that a global object is not destroyed when moving from one layout to another. I am more confused as to why the number of instances of my global object increases when transitioning between layouts.

From my understanding, I should only have 1 instance of each global object, that does not increase as I transition between layouts, especially in the event where the global objects are exclusively created via placement in the editor (as in my capx).

I just cant quite see what I am missing here....
B
5
S
1
Posts: 4
Reputation: 283

Post » Tue Mar 17, 2015 1:29 pm

You also use a global layer .....
Who dares wins
B
56
S
15
G
17
Posts: 1,843
Reputation: 17,287

Post » Tue Mar 17, 2015 5:48 pm

Doh, so simple and obvious, I'm embarrassed I did not notice it myself.

Thank you Iennaert ! :)
B
5
S
1
Posts: 4
Reputation: 283

Post » Tue Mar 17, 2015 5:57 pm

No worries, as I said earlier to another scirrian, it happens to the best of us :D
Who dares wins
B
56
S
15
G
17
Posts: 1,843
Reputation: 17,287


Return to How do I....?

Who is online

Users browsing this forum: imhotep22, LunchboxGames and 6 guests