how do I move a Array from a layout to another

Get help using Construct 2

Post » Wed Nov 23, 2011 5:55 pm

Hi!

Here's my problem.
I have a array in layout2.
My game starts with layout1.

So I can't access or change data in my array in layout2.
My Array is Global, but I guess that if it wasn't loaded at least once, I can't access it. anyway, it doesn't work.

I'd like to do that, be able to access and change the data in my array.

So I thought that I need to move the Array to layout1, but... how do I do that ??

Thanks

B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Post » Wed Nov 23, 2011 8:49 pm

you cant right now, dont know if that will change
my solution was making a new array on layout one, replace all the actions with the new arrayobject

the problem next is that you need to always launch from layout 1,

therefore i used in layout2 > system compare if array.count=0 gotolayout 1
and on layout1 you have a redirect to layout 2 or a button that connects to the other layouts
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Wed Nov 23, 2011 9:42 pm

But i have too many actions...
That's something missing also in Construct, if I may...
The "replace" fonction.
to replace an object by another in the Event sheets...
That would be great!
B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Post » Thu Nov 24, 2011 1:11 am

There's a solution.
Your main problem is that you put your Array in a layout that appear after the first layout that have to USE this array.

Basically, you want to move the array to the other layout.

1/ Save as Project in projectfolder (name it as you see fit)
2/ Go to projectfolder/Layouts/
3/ Open the xml file of layout where your array is
4/ Locate it in the xml gibberish it should look like :
[code]<instance type="Array">
    <properties>
        <width>10</width>
        <height>10</height>
        <depth>10</depth>
    </properties>
</instance>[/code]5/ cut this
6/ Open the xml of the layout you want your array to be
7/ locate the nonworld-instances element
8/ if you don't have non world element in this layout it should look like
[code]<nonworld-instances/>[/code]That's the syntax for empty element
In this case you will have to change this markeup to
[code]<nonworld-instances></nonworld-instances>[/code]To be able to put something inside.
9/ paste inside the nonworld-instances element
[code]<nonworld-instances>
    <instance type="Array">
        <properties>
            <width>10</width>
            <height>10</height>
            <depth>10</depth>
        </properties>
    </instance>
</nonworld-instances>[/code]10/ save and close both xml file
11/ open the projectfoler/project.caproj

it should work...

in any case you take no risk as you always have your original .capx
also if you manage to get the hang of xml syntaxe, you can easily make some "replace" operation in the event sheet xml (projectfolder/Event sheets/)Yann2011-11-24 01:16:47
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Nov 24, 2011 4:31 am

wow nice tip, gonna look into that
ImageImage
B
61
S
19
G
6
Posts: 809
Reputation: 9,028

Post » Sat Nov 26, 2011 12:12 am

Yep ! Thx, I'll try this!
thx a lot!
B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Post » Sun Nov 27, 2011 10:02 pm

It worked !

Thx a lot !
B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Post » Sun Nov 27, 2011 11:55 pm

The next build (r70) always creates global arrays on the start of the project rather than leaving it until you visit its layout. Hopefully that will also fix it.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,554

Post » Mon Nov 28, 2011 4:55 am

I've seen that !

It's great
B
12
S
2
G
5
Posts: 73
Reputation: 3,570

Post » Sun Feb 19, 2012 6:17 am

Please please fix this bug. It is really trying and even with the hack fix of modifying the XML, it is still very tedious.

Of course the real fix is to make it so you don't have to have at least one instance in a layout to use it!
B
14
S
4
G
4
Posts: 20
Reputation: 3,676

Next

Return to How do I....?

Who is online

Users browsing this forum: anty21ro, Braus and 2 guests