Instance IDs, spawning instances with different PV values

For questions about using Classic.

Post » Fri Oct 09, 2009 7:52 pm

First things first, I'm fairly sure that the answers to my questions can probably be found somewhere in the forums, a tutorial, or the wiki, but my best efforts haven't turned up anything. But I won't be offended if an answer is a link to a resource, hah.

Here's my problem: I have an object with a lot of private variables that I'm tracking. I want to spawn different instances of this object, and I want to control what the values of those PVs are for each individual instance as it spawns.

Example: Let's say I've got a "wave object" with the private variables speed, momentum, and volume. When this wave collides with a rock, I want to spawn a second wave with all of the same properties and whatnot, but with different speed, momentum, and volume values.


My second question is more general: Where can I learn more about how Construct handles referencing instances of the same object? How does it know which instance I'm referring to when I have an event that does something to an instance of an object? Is there a way that I can grab a value from a specific instance without grabbing from the others? Etc. I basically just want to educate myself in this area a bit more, because I'm instancing a lot of objects and I anticipate having more questions.

Thanks in advance!
B
1
G
3
Posts: 4
Reputation: 833

Post » Fri Oct 09, 2009 8:34 pm

[url:2lbumlqx]http://sourceforge.net/apps/mediawiki/construct/index.php?title=Conditions[/url:2lbumlqx] :mrgreen:

You have to filter the SOL (selected object list) with condition picking. Imagine all the instances start out picked, and each condition eliminates instances from the sol which don't return true on the condition.

For setting pv's when spawning, it depends on what version of construct you're using. In all versions, you add a spawn object action, then a set variable (or any other action) right after it, and it will pick only the spawned instance. Be careful with multiple spawning of the same insance in a single event:

in 98.9
You cannot put multiple spawn+set events in a single event or subevent and expect it to correctly pick and set each object's pv. To have multiple spawns of the same instance with different pv settings each time, you must make subevents (with just an ALWAYS condition for instance) for each one.

in 99.42

you can have multiple spawn + set events in a single condition, and it will pick the last spawned sprite.
B
25
S
3
G
6
Posts: 1,197
Reputation: 5,620

Post » Wed Oct 28, 2009 5:44 pm

Just realized I forgot to actually thank you!

Yes, this information definitely helped me work that out. Thanks a lot, Davio.
B
1
G
3
Posts: 4
Reputation: 833


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests