[SOLVED]Spawn instances of spr from same spr

0 favourites
From the Asset Store
Act on your instances, get/set their properties and variables only thanks to their UID. No more picking trouble! Plugin
  • Alcemon - i am curious as to why is it important to spawn them FROM the "default" sprite. why not just spawn them using the system event and then position them according to where the default sprite is spawned?

    it seems a lot less finicky using "system - create object" rather than "sprite - spawn another object", is there a particular reason you want the sprite to spawn the clones?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • R0J0hound thanks for your answer. I initially thought it answered everything but I did find an inconsistency that I wanted to address.

    Please look at the following snippet(sorry, I could not direct embed from a google drive image)

    docs.google.com/file/d/0B20uobjbjbtgS2tjX25TTTZPOG8/view

    The scoping rules that you mention in your two links are not breached. And yet it does not work as it should, as running that code would spawn infinite instances of Sprite1 as opposed to only 2.

    wretchedshark currently the thread is not so much about "getting something done in any way" (which in hindsight, WOULD be the objective of the "how do I do..." subforum). Many of the proposed solutions in the thread already answer the original question.

    It is more about finding an explanation for a C2 behavior I did not not anticipate or understand (as maybe it is known limitation, bug?).

  • Now I see the problem, it's a bug, spawn doesn't pick the new object.

    The workaround would be to use the System->Create action instead of Sprite->Spawn. For the position use Sprite.ImagePointX(2) and Sprite.ImagePointY(2).

  • Alcemon - ah i see, then i think it is simply a case of how the function in the program handle things

    system - create - each sprite can be set and individual instance variable while the spawning is happening

    sprite - spawn object - setting variables while spawning keeps the original sprites values (in my experience)

    you can do a workaround to get the desired behaviour (using system) or you can use a workaround inside of using sprite - spawn another object.

    this seems handy in that say you have an enemy you could have it spawn direct clones (using sprite spawn another object) or have it spawn weaker clones (using system and setting its health variable or defense etc).

    i will have a look again later and look for more ways to accomplish what you are hoping to achieve within sprite spawning another object <img src="smileys/smiley1.gif" border="0" align="middle" />

  • 'System: Create Sprite' picks the newly created Sprite.

    'Sprite: Spawn Sprite' doesn't pick the new Sprite - the original one remains picked.

  • 'System: Create Sprite' picks the newly created Sprite.

    'Sprite: Spawn Sprite' doesn't pick the new Sprite - the original one remains picked.

    ramones Wow! Thank you ramones, this is exactly it.

    In the end it was not a bug or a limitation. I think it's an undocumented behavior (as the manual entry for 'Create Sprite' and 'Spawn Sprite' do not mention this difference) that comes to light *ONLY* when the same sprite is spawning instances of itself.

    To explain it even better, we all thought that 'Spawn' ALSO picked the spawned object because code like the following would run without problems (again sorry for not embedding I can't seem to tame Google Drive for that):

    It seems like spawn it's picking but its not

    But the reality is, as ramones said, that Spawn *DOES NOT* pick the created instance (it just happened to get picked when we were spawning different instances because it was the most recent instance for the 2nd sprite in that scope).

    Thanks everyone, I am adding "SOLVED" to the topic.

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