Referencing specific instance of multiple duplicate objects

For questions about using Classic.

Post » Thu Jun 25, 2009 10:50 pm

I'm having trouble writing Events/Actions that deal with a particular instance of an object, when I have multiple instances of an object in the layout. Specifically, there's 64 instances of sprite A (in an 8x8 grid) and one instance of sprite B. When sprite B overlaps an instance of sprite A (#1), I want to set a private variable in sprite B based on the animation frame of the overlapped sprite A, then move sprite B over a different sprite A (#2), and compare the sprite B private variable to the animation frame of sprite A #2.

The first part works fine (set the sprite B private variable), but the second part (the comparison with sprite A #2) doesn't seem to be working; from what I can tell, it's doing the comparison between sprite B and sprite A #1, instead of between sprite B and the sprite A #2.

I really hope this makes some kind of sense, and that someone can help. If there's something helpful and applicable that I missed in one of the tutorials, kindly point the way. I'll try and figure out how to post the .cap, which I'm guessing would also be useful. Edit: Here's a link. The relevant code is under the 'Move Attempt' group.

Alternately, if anyone has any better suggestions on how to go about putting together a Match-3 type game in Construct, I'm all ears. As awesome as Construct is, it's still forcing me to exercise the computer science/math/logic parts of my brain that I haven't used properly in years.
B
1
G
3
Posts: 6
Reputation: 837

Post » Fri Jun 26, 2009 11:20 pm

when using a 'Object A is overlapping/colliding with Object B' condition, Construct automatically puts the two objects in question into the SOL (selected objects list), meaning that any following Actions will always deal with the colliding/overlapping instances of A and B. since the loop that moves your collision-checker is a subevent of an event using that kind of condition, it can always only refer to the same instance.

a solution to this could be to restructure your code, so that the collision detection takes place in a subevent and does not influence picking adversely. or you could use families as a workaround: since it is possible for an object to belong to two different families, you can use that to pick object's outside of the current SOL (e.g. check collision for Family A (which reduces the SOL of Family A to a single instance), then afterwards loop through Family B (whose SOL still contains all instances), with Object A belonging to both).
B
2
S
2
G
4
Posts: 171
Reputation: 1,792

Post » Sat Jun 27, 2009 5:39 am

[quote="dkdoom":ammcr04z]when using a 'Object A is overlapping/colliding with Object B' condition, Construct automatically puts the two objects in question into the SOL (selected objects list), meaning that any following Actions will always deal with the colliding/overlapping instances of A and B.[/quote:ammcr04z]

That confirms my suspicion. I'll try restructuring my code with this in mind. Thanks for the info and the suggestions.
B
1
G
3
Posts: 6
Reputation: 837

Post » Sat Jun 27, 2009 2:19 pm

Also, you could use a global variable to store the instance's pvariable value and use a function call wtih "forget" picked then repick in the function with global being equal to the pvariable.... But I'm bad at Construct and make mistakes all the tinme, so don't listen to me.
B
2
S
2
G
4
Posts: 259
Reputation: 1,968

Post » Sun Jun 28, 2009 8:53 pm

but you're right, the fact that Functions can be made to "forget" the current SOL is another workaround for this kind of problem. (i forgot about that one, too...)
B
2
S
2
G
4
Posts: 171
Reputation: 1,792


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests