Question about global objects...

For questions about using Classic.

Post » Tue Jul 12, 2011 1:46 am

I learned the hard way that having a global object on every layout is a recipe for disaster, since you're going to end up having a million copies of the same object.

My question is, should I have all global objects on one layout when the application begins that the player CAN'T return to? Right now, I have Title Screen -> File Selection - > World Map, etc., etc. On that first layout, the title screen, is where all the global objects are created. However, the player can cancel out of the file selection and return to the title screen at any time. Wouldn't this end up creating another batch of global objects each time, thus causing problems? So correct me if I'm wrong, but wouldn't the ideal solution would be to have a layout before ANYTHING in the game begins that stores all the global objects, that the player can't return to?
B
4
S
2
G
4
Posts: 164
Reputation: 1,878

Post » Tue Jul 12, 2011 3:29 am

I only use global on a few objects, xaudio, function, keyboard & mouse etc and I do use a layout at the start for those objects. It is going to be a splash screen or something so it will be useful but there won't be any reason to go back to it.
B
9
S
2
G
4
Posts: 346
Reputation: 2,726

Post » Tue Jul 12, 2011 3:41 am

No, having a global object on the first layout will not result in more instances being made if you leave that layout then go back to it. You can check for yourself how many instances there are via the debugger.Arima2011-07-12 03:42:06
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,432


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 9 guests