[r98] Duplicating layout duplicates global objects

Bugs will be moved here once resolved.

Post » Tue Jul 10, 2012 5:30 am

Hey hey. Not sure if this can really be called a bug, its more of an inconvenient behavior.

So I've been playing around with a bunch of global arrays to hold information for my game. I've finished the level prototype and I am ready to begin creating new levels. However, when duplicating the prototype level, the global arrays are also duplicated. Unfortunately this is a bit game-breaking for me as I use a lot of 'For Each Element' loops. Their doesn't seem to be a convenient way to delete the arrays from the layout - and I only ever need one for the entire project.

Here's an example where I:
  1. Created an array
  2. Duplicated the layout


http://dl.dropbox.com/u/1378330/ArrayExample.capx

Is there an easy way to delete global objects from a layout? Or could we possibly get a dialogue that asks us if we want to duplicate global objects when duplicating a layout?cow_trix2012-07-10 05:42:55
B
55
S
12
G
8
Posts: 339
Reputation: 9,314

Post » Tue Jul 10, 2012 11:55 pm

In the future, you might start your projects by creating an "object bank", which is simply a layout that isn't really used for anything except to hold your global objects and to keep a copy of objects you want to spawn/create during the game (to get around the limitation that there must be at least one copy existing somewhere.) So your audio, arrays, etc. would all go here as well as an instance of every object that doesn't appear at the start on your layout.

All very well and good, but you need to solve your current situation. Here's how I'd do it:
1) Backup your game, and, working with a copy,
2) create a new empty layout with all of the layers in your existing prototype layout, and name it Template
3) lock all of the layers in your prototype layout and one layer at a time unlock the layer, select all of the objects on the layer and paste them in the corresponding layer on the Template layout.
4) When all of the objects are correctly in place on the template layout, set its event sheet and test it.
5) If testing goes well, use the Template layout as the starting point for your new levels. You can keep the original prototype level as it is, or delete all of the unnecessary objects from it and rename it "Object Bank".
6) When you finish your game, you may want to delete the Template layout, or rename it and use it as your last level.

Hope that helps!
B
29
S
11
G
12
Posts: 281
Reputation: 11,878

Post » Wed Jul 11, 2012 3:42 pm

@cow_trix - I do think this is a bug so I've changed it in the next build to not duplicate invisible instances.

You can remove invisible instances by hacking the project XML. The invisible instances are in the layout's XML file under a tag called 'nonworld-instances'.
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Thu Jul 12, 2012 3:53 pm

Should be fixed in r99, can you confirm?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,528

Post » Fri Jul 13, 2012 6:07 am

Hi Ash. It worked - however, because I already had multiple instances created from duplicating the layout, deleting the duplicated layouts did not delete the duplicate global objects, so those I had to delete manually. However, from this point on it should all work fine. Thanks!
B
55
S
12
G
8
Posts: 339
Reputation: 9,314


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 3 guests