Plugin/extension that allows instance grouping?

Discussion and feedback on Construct 2

Post » Sun Jan 25, 2015 12:08 am

Ok, you've helped a lot so far, thank you so much! I still am having trouble with the for loop though. I can almost see what I need to do it's just not quite coming together yet. Here's what I have so far:
Image
I'm using the rex_nickname plugin to spawn objects based on a string, so it gets the name of the prefab sprite first (which is the first token value) and then spawns it, but then I can't quite figure out how to spawn in the other objects on top of it at the right imagepoint. Any ideas?
B
5
S
1
Posts: 59
Reputation: 497

Post » Sun Jan 25, 2015 3:18 pm

I haven't used Rex's nickname plugin at all. Apologies! The method I normally use is:

1) Make sure each of the prefabs are gathered together in a Family, and create a family (string) variable called "Tag."

2) Give all of the backdrop prefabs a "basic" tag (like "Platform Prefab," "Climb Prefab," etc.).

3) After the backdrop has been spawned in, add the loop index to the tag of the backdrop. If I spawn in a "Platform Prefab" backdrop on the second loop iteration (e.g. LoopIndex = 1), then its tag becomes "Platform Prefab 1". This is for the next step in case you happen to have duplicate prefabs throughout the level. If you end up deleting the backdrops after each of them has spawned in its pieces, adding the loop index is unnecessary (since there will never be more than one backdrop being spawned in at a time).

4) Create individual spawn-in functions for the pieces. For my method, each function would contain two parameters: an integer for the image point (either drawn from the array, or with the loop index method I described on the previous page), and a string for the tag of the last spawned-in backdrop prefab. The function would first create the piece. Then, it would pick from the backdrop prefab Family using a comparison check (BackdropFamily.Tag = Function.Param(1), or whatever index you selected to inject the backdrop tag into) and attach the newly spawned piece to the picked backdrop prefab's image point (obtained from the function parameters again).

With rex_nickname, you might not need to create multiple functions, but, instead, a single "master" function for spawning all of the pieces in. You would need a third parameter (the string needed to spawn in the piece, which can also be obtained from the array) for the function. I'm not sure how rex_nickname works with regards to object picking (that is, whether the last-created object is always picked in subsequent events), but the method should be similar to the above.
B
5
Posts: 13
Reputation: 251

Post » Sun Jan 25, 2015 8:11 pm

Again thank you, you've helped me figure out how to set it up with the nickname plugin with your explanation. It now looks like this:
Image
There's just one tiny thing wrong now, the for loop I circled doesn't seem to be working properly. What I did is in my CSV string I also stored the coordinates that the pieces of each prefab need to spawn at and I parse them with semicolons. The string looks like

ThreePlatforms,Platform;0;688,Platform;320;576,Platform;624;448,,,,
So it gets the prefab name, the piece of the prefab, then it can parse through each piece and get the coordinates.
It's returning the data properly if I just look at the individual tokenat statements ( example: int(tokenat(tokenat(P,loopindex,","),2,";")) ), but the for loop I circled doesn't seem to be executing properly. I need it to cycle from 2 (where the first piece's name is stored) to the last one, and I thought that would work but it doesn't. Any ideas?
B
5
S
1
Posts: 59
Reputation: 497

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 9 guests