How do I spawn sprite instances specifically?

0 favourites
  • 8 posts
From the Asset Store
Pixel Sprites ala ReactorCore - Builder Hardware - Large pack of sprites!
  • As a follow up to my attach sprite topic, but this time with spawn of sprite2 instances. I'd hope for the same color to spawn from the same spot such that yellow spawns from top left, blue from top right, pink from bottom right, and green from bottom left in that order, but I'm currently having trouble setting up the rotational order of sprite2 to spawn in time. Instead all sprite2 instances spawn in the same top left corner...

    I can provide examples of my code in screenshot form when asked.

  • You definitely need to attach some screenshots of your code and of the result you are trying to achieve.

  • The image below shows my code.

    I'm still trying to familiarize myself with the loopindex option and I think that's where the fault may lie in this code.

    This shows where the spawn is planned to be. The four colors indicated by the arrows correspond to the instance colors I wish to have on each corner, which I already have as Sprite2 (Molek) instances. The colors don't actually show because they're randomly generated.

    As well as this, I hope for there to be a path of a quadrifolium until it is collected by the core (in black) to which the previous attachment code is already at play.).

    Each molek can go either clockwise or counterclockwise. This part might be easiest to code for me, since I've had help figuring that part out. However, spawn points as related to color? That's new to me.

  • I should also mention that in the above example, there's also a timer that runs to spawn another molek in (I was hoping) the order of last color and corner, since if Chemic (in black) does not collect Molek in X seconds, and there aren't 4 instances already present that aren't collected, to spawn in another, again in that order.

    That sounds like a function involving a variable to me, but I'm not certain on that, or even how to write it down as one, if at all.

  • The code is quite a mess to be honest. You need to understand how picking works in Construct!

    Once you create/spawn a new Molek instance, it gets automatically picked in all the further actions and sub-events. I outlined all these lines with red - they apply to the created instance only:

    So the sub-event #27 will compare the color value of the newly created instance only, not any of the other existing instances! Which means "Or pick Molek instance 2" condition is moot, because the picked scope only contains 1 instance.

    If you want to compare other instances in a sub-event, you need to use "Pick all" condition first. But then you will need to pick the newly created instance again to change its color variable.

    Can you explain what these particular events 26-27 are supposed to do? And then I may be able to tell you how to fix them.

  • The "overlapping at offset" condition is also used incorrectly.

    You probably need "System Pick overlapping point" instead.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • The code is quite a mess to be honest. You need to understand how picking works in Construct!

    Once you create/spawn a new Molek instance, it gets automatically picked in all the further actions and sub-events. I outlined all these lines with red - they apply to the created instance only:

    So the sub-event #27 will compare the color value of the newly created instance only, not any of the other existing instances! Which means "Or pick Molek instance 2" condition is moot, because the picked scope only contains 1 instance.

    If you want to compare other instances in a sub-event, you need to use "Pick all" condition first. But then you will need to pick the newly created instance again to change its color variable.

    Can you explain what these particular events 26-27 are supposed to do? And then I may be able to tell you how to fix them.

    I thought it might have been messy lol

    I tried to make a check of color Molek already spawned before, so that the other color of order would show. For instance, if spawned blue, then pink would show next, or if spawned yellow, then blue, and for each corner to correspond to the color (a part I may have neglected, in retrospect).

  • I still don't fully understand your task, but in any case the code you have is very wrong.

    This whole thing can be done much easier. Decide which color molecule to spawn (a number from 1 to 4). Then, since each color is spawned from a separate image point, you can simply use the color number to spawn a new molecule:

    dropbox.com/scl/fi/0jqup6qr3zuoyfdomsdiz/Moleks.c3p

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