[r114] Troubles With Array and Containers

Bugs will be moved here once resolved.

Post » Wed Jan 16, 2013 5:02 pm

This is a re-post of a topic I started in the "How Do I...?" forum:


Howdy folks!

I'm having some trouble with using arrays with containers.

Here's what the manual states:

"It's possible to add data storage objects like Array and Dictionary to a container with another object. Despite the fact these objects are invisible, a separate instance of the object is still created for each container. This allows you to have a dedicated Array or Dictionary for each instance of an object. This can be very useful as an advanced substitute for instance variables, such as if a very large number of variables is necessary, or if variables need to be dynamically added and removed."



But I've found this to be untrue. When I add an Array to a container, it doesn't automatically instantiate/destroy new copies of that array when the container object is created/destroyed.


Has anyone else found issues with this?

Here's an example .capx to demonstrate what I'm talking about.

ArrayCreationTest.capx

In this demo, every time the player clicks, they should see the text "Created Array"

But the arrays aren't being created for some reason...


Help please?

Thanks,
Sam
B
5
S
1
Posts: 4
Reputation: 858

Post » Wed Jan 16, 2013 5:18 pm

Or rather, to clarify, there seems to be two issues here:

The "On Created" event is not called when an Array is created via a container object.

Unlike other container objects, it is not possible to automatically pick the right instance of the associated Array by picking an object that contains it in an event sheet.
B
5
S
1
Posts: 4
Reputation: 858

Post » Fri Jan 18, 2013 1:55 pm

According to this test (note: created with r116, just out) it works as the manual describes:
https://dl.dropbox.com/u/15217362/r116-arraycontainerworking.capx
You can see each array storing a value uniquely, like an instance variable. So I think this is working OK and there is just a mistake in your events. However I did notice 'On created' is not triggering for the Arrays in containers. I'll have a look at fixing that for the next build.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Mon Jan 21, 2013 10:31 am

I ran into same problem with 'on created' not triggering on any container objects. Here is an example capx: On created problem

It's easy to observe if you switch the action inside 'on created' event to buttons 'on clicked' event.
B
24
S
8
G
7
Posts: 756
Reputation: 7,192

Post » Mon Jan 21, 2013 11:36 am

OK, should be fixed in next build... but I noticed 'On created' doesn't trigger for objects already in the layout. To keep it consistent with this, the same is true for objects in containers.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Thu Nov 19, 2015 11:11 pm

Hey looks like this is kinda dead but I'm having the same issue. I put an array in container with a sprite and try to set a variable for that sprite using the values in the array but it doesn't work
B
17
S
6
Posts: 169
Reputation: 1,659

Post » Fri Nov 20, 2015 1:15 pm

@bbjGames - please file a new report following all the guidelines.
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Fri Nov 20, 2015 9:34 pm

Ok
B
17
S
6
Posts: 169
Reputation: 1,659


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest