Just curios: Why is array a seperate object type?

  • to Ashley

    If I want to use an array it has to be added as a seperate object, why is it not a type of variable that can be created as an instance variable? Would make them much easier to use I think.

    Thanks!

  • Yea but arrays can be created and destroyed in events during runtime and can also be members of families with family variables and can also have thier own set of instance variables.

  • Arrays are already easy to use. If it was an instance variable then what value is object.array?

  • Try putting an array as a container.

  • It’s probably a throwback to how arrays were separate objects in Clickteam products.

    Also it does help keep things tidy to have the array actions and conditions grouped together. At least with how types are handled currently.

    Construct classic actually had a way to assign arrays to variables, although they were pretty much constant. You couldn’t change the size or elements of it, and it wasn’t supported in all places. The feature didn’t make the jump to C2.

    I think it would nice be have as a variable type though. If it made the array object obsolete I wouldn’t mind, as soon as you do something moderately complex that involves picking you realize containers don’t really help a lot.

  • As it is now, I avoid arrays because it gets complex and fiddly to use them with all the referencing UID's back and forth etc.

  • I agree that Construct's arrays in general feel somewhat fiddly.

    I haven't had time to take a closer look at the new JavaScript features so no idea if they work that way but maybe it can be used to declare a "real" JS array and use where needed?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • One of the big problems is handling memory management. Suppose there's an array expression type and you store a 10mb array inside an object's instance variable. Now how do you set a single value in that array without needlessly copying the entire 10mb array? There is both an efficiency problem (e.g. using 'Set instance variable' with some expression that copied the entire array and just changed one element would be super inefficient) and a user experience problem (how do you do 'set element at' in values that are stored somewhere else, e.g. in an instance variable? Is the action to do that still in an 'Array' object? Do we have to start explaining by-value and by-reference semantics to understand expressions?)

    Keeping a single array in a separate object avoids all of these problems.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)