An array of graphical objects?

This forum is currently in read-only mode.
From the Asset Store
Supports 1D, 2D, 3D arrays. Import and export arrays in JSON format
  • I read somewhere within the forums that one could make an array of objects, for example sprites.

    I cannot possibly figure out how this is done. Can someone elaborate? I saw a spawn action typed somewhere, but couldn't get to it myself. Just now figured instancing with ctrl-dragging.

    I'd like to get an array of 1px-high tiledbackground instances, vertically arranged.

  • Why not just stretch the tiledbackground?

    But if you're doing something different, you can do an array paste for objects in the layout editor. Just copy an object, right-click the layout, and then click "Array paste". You can set all the options like X and Y spacing, angle, size, and the amount of objects in the window that pops up.

  • Is there any way to access the pasted objects by index?

    Array paste appears to just help aligning multiple instances, and the Array object seems to be a standard data array.

    Which is the best way to access an object by an index? I want to loop on them and execute actions on each (change position, stretch, etc) based on the index, but I don't quite understand the loop action.

  • Ah, I see. I can't really express how to do it in words, but here's a quick CAP I whipped up showing how to mess around with sprites based on their index: Sprite array thingy.

    Not the best demonstration, but I hope you get the idea.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • O_O bizarre, when I tried to open it Construct complains that "the file was saved in a newer version of Construct", yet update reveals I'm using the latest (0.98.7)

  • There is a new version out, but we don't put it on the autoupdate for a few days incase of serious problems.

  • that worked.

    The cap illustrates exactly what I wanted to know, thanks.

    For others reading this thread:

    Set a private variable Index in the object, place one copy in the layout.

    events:

    on layout start destroy the object, then loop and spawn objects setting the index variable to the current index, increment index manually inside the loop.

    always loop foreach object, do whatever with the index.

    cool. Will play extensively with this. Oh yes.

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