Problem with global array

Get help using Construct 2

Post » Thu Jan 26, 2012 4:45 am

-I have a Array object (Foo) under my 'object types' that is set to 'Global: yes'

-I have an event that sets the size of Foo to (5,5,1)

-I have an "for each XY element" condition whose action for Foo is to set value at (Foo.CurX, Foo.CurY) to 7

When I check my values (by updating text every tick), it says that Foo.Width is zero and Foo(3,3) is 0. Width should be 5, and the value of any cell should be 7.

What am I doing wrong? I don't need to create an instance of my array, do I?
B
11
S
2
G
1
Posts: 8
Reputation: 1,414

Post » Thu Jan 26, 2012 8:09 am

need capx

... Well as you made a clear description, I applied all you said in a capx and I have to say...
It works fine so far (:

ArraySetting.capx
Last edited by Yann on Sun Sep 14, 2014 9:49 pm, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Thu Jan 26, 2012 4:36 pm

Yeah, I dumbed down my example a bit. I've got multiple layouts and multiple event sheets and stuff like that -- maybe the problem is somewhere there.

I'll try simplify and repro the issue tonite, and check out your capx.

Thanks!
B
11
S
2
G
1
Posts: 8
Reputation: 1,414

Post » Fri Jan 27, 2012 4:06 am

Okay, check out this capx
http://dl.dropbox.com/u/57805068/BrokenArray.capx

I don't know how I did it, but one of the arrays (BrokenArray) doesn't have any instance variables or properties. And it's listed under Objects, but not under "All Layout 1 Objects". And that's the array that is gimpy.

Maybe I don't understand something about object scope or something...?kirkthejerk2012-01-27 04:07:19
B
11
S
2
G
1
Posts: 8
Reputation: 1,414

Post » Fri Jan 27, 2012 4:34 am

I guess you created "BrokenArray" in a layout that you later deleted.
What this means to C2 is that now BrokenArray has no "default instance".

This make things bug on preview, it is a known issue that is to be fixed. (the "no default instance" part)

I guess that your problem at first was that you were trying to use the array in a layout where it hasn't been instanciated yet.
(For example, you're in layout1, you created brokenarray in the layout2 and you're trying to access it in an evensheet from layout1)

I think like you suspect this is a scope problem.

The best thing to do here is to create a new Array object in the current layout and simply delete "brokenarray" as unusable.

New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,805


Return to How do I....?

Who is online

Users browsing this forum: selaus and 0 guests