efficiently handling multiple instances of the same object.

For questions about using Classic.

Post » Tue Sep 30, 2008 7:16 am

whats the most efficient way of handling multiple instances of the same object?

for example, creating 2 of the same object at different image points and then setting their positions to stay on these points via an ALWAYS , or getting them to behave differently, like changing their angles independently.

thanks
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Tue Sep 30, 2008 7:59 am

Recently, there has been a lot of discussion of things like that. If you have to do something to a independent instance, you must pick it. The actions in an event apply only to picked objects, so you must ensure that only the instance you want to manipulate gets picked. You can pick with Unique Identifer, for example. For each -condition is also a lifesaver, it loops through every instance of an object so that the event is performed once for each instance.

I'm in uni now and I should be studying (deadlines :S), so can't blabber more. Sorry :D
B
3
S
2
G
5
Posts: 263
Reputation: 2,201

Post » Tue Sep 30, 2008 8:20 am

Picking is handled automatically for a lot of things.

For instance, if you say "sprite is overlapping ground -> destroy sprite" then only the sprites that meet the condition are picked and destroyed.

If you know the unique ID of an object, you can pick it that way as well.

If there are no easy ways to pick like that, or you know you will have situations where some objects might meet similar criteria, you can make your own ways to pick with variables. Give each of your sprites a private variable, and make it unique. Then you can do "sprite.value('myvariable') equals whatever -> do something."
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Tue Sep 30, 2008 9:53 am

Idea of sub-events, sub-animations and stuff seems to cover this problems. But while its usage is still unclear to me, it'd be good for someone from DevTeam to tell about it ^^.

Theoretically when conditions needed to make two objects are met, then you would have to make two parallel sub-events - both "always"-ed. First one will handle making first object and initializing it, second one: handle second object.
B
6
S
3
G
6
Posts: 219
Reputation: 3,013

Post » Tue Sep 30, 2008 11:43 am

[quote="BROO":23lbc174]Theoretically when conditions needed to make two objects are met, then you would have to make two parallel sub-events - both "always"-ed. First one will handle making first object and initializing it, second one: handle second object.[/quote:23lbc174]

Yep :). That's because Selected Object Lists descend to subevents, but not back from subevent to parent event or sibiling event.
B
3
S
2
G
5
Posts: 263
Reputation: 2,201


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 0 guests