How do I pick a instance by comparing according to instance variable ?

From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • I'm building an engine to populate a layout with instances by using an array that contains instance X and Y, opacity, visibility, etc.

    Instances are connected between them and array also contains their connections in a way that if I click on an instance, the related instance will flash. This is determined by the column called Next in the json. In this case, Instance 1 flashes Instance 2, Instance 2 flashes Instance 3 and

    Instance 3 flashes Instance 1.

    So far, I was not able to build this connection between sprite. My attempt is line 5 and 6 of the code.

    I'll be grateful if someone could help me with this.

    Also : I'd like to have more than one connection between instance. For example, instance 1 when clicked flashes instance 2 and 3. I thought about populating the array with strings like "2,3" but don't know how to parse them.

    C3p can be found here https://www.dropbox.com/s/lyvoap25so4bs6p/SpriteFromArray_Test.c3p?dl=0

    Tagged:

  • You could either pick all sprites again using system pick all and then use your pick condition (within the same sub event) or you could use a function and pass the values through as parameters to pick the correct sprite.

  • You could either pick all sprites again using system pick all and then use your pick condition (within the same sub event) or you could use a function and pass the values through as parameters to pick the correct sprite.

    Thank you ! I managed to do it following your first suggestion but I'm very curious to see how you would code the second one.

    Any idea on how to code link to multi instances ?

  • My approach would be to have the next instance variable with all the instance IDs so it could be "1,2,3" then you could use the tokenat expression to grab individual numbers, and use a loop to run through each picked instance. If you can't work it out maybe I can add to the project file if I have time.

  • My approach would be to have the next instance variable with all the instance IDs so it could be "1,2,3" then you could use the tokenat expression to grab individual numbers, and use a loop to run through each picked instance. If you can't work it out maybe I can add to the project file if I have time.

    Thank you ! Indeed, it's beyond my skills. Actually, this loop approach would be to allow to spawn more than one instance when a sprite is clicked. for example, when sprite with SpriteID = 1 is clicked, create instances with SpriteID 2 and 3.

    I updated the file here : https://www.dropbox.com/s/3b7b6q09kuwkybx/SpriteFromArray_Test.c3p?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There ya go : dropbox.com/s/g6vk2edgy81lmrw/spritecoordinatearray_edited.c3p

    edit : ok I see you want to spawn the sprites instead of flash, well use my logic and instead use create sprite action and also an action of set ID to the tokenat value displayed in the condition at line 9

  • There ya go : dropbox.com/s/g6vk2edgy81lmrw/spritecoordinatearray_edited.c3p

    edit : ok I see you want to spawn the sprites instead of flash, well use my logic and instead use create sprite action and also an action of set ID to the tokenat value displayed in the condition at line 9

    Thank you very much !! I managed to adapt your tip to create sprites.

    Here's the file, if it can be useful to anyone : https://www.dropbox.com/s/oaq41k1xn2fuw0m/MapFromJson.c3p?dl=0

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