How do I generate objects in order between other type of objects.

0 favourites
  • 3 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • On level there are located lots of objects (named choosearea). This object has instance variable "sequence". What I want to do is, on start of layout to generate another type of object (named coinreal) between each 2 choosearea instance with adjacent "sequence" values. (for example, object "coinreal" should be spawned between objects "choosearea" with "sequence" values 1 and 2, 2 and 3, 3 and 4 etc.)

    On illustration below I show how it should look:

    At first I thought it will be easy to do, but something is wrong with the "for loop" I made. (nothing happens at all). This is probably very trivial, but im kinda confused right now :(

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The issue you’re seeing is you cannot pick two separate instances of an object like that.

    One common solution is to use a family with just that type. But you’d need to only add instance variables to the family.

    For each sprite
    Other: instance = sprite.instance+1
    — create spriteB at (other.x+sprite.x)/2, (other.y+sprite.y)/2

    Another idea is to pick one, save the data you need to variables, use “pick all”, then pick another.

    Var otherx=0
    Var othery=0
    Var otherInst=0
    
    For each sprite
    — set otherx to sprite.x
    — set othery to sprite.y
    — set otherInst to sprite.instance
    — pick all sprite
    — sprite instance = otherInst+1
    — — create spriteB at (otherx+sprite.x)/2, (othery+sprite.y)/2
  • The issue you’re seeing is you cannot pick two separate instances of an object like that.

    One common solution is to use a family with just that type. But you’d need to only add instance variables to the family.

    For each sprite
    Other: instance = sprite.instance+1
    — create spriteB at (other.x+sprite.x)/2, (other.y+sprite.y)/2

    Another idea is to pick one, save the data you need to variables, use “pick all”, then pick another.

    Var otherx=0
    Var othery=0
    Var otherInst=0
    
    For each sprite
    — set otherx to sprite.x
    — set othery to sprite.y
    — set otherInst to sprite.instance
    — pick all sprite
    — sprite instance = otherInst+1
    — — create spriteB at (otherx+sprite.x)/2, (othery+sprite.y)/2

    Thanks man! Family solution totally works.

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