Breaking 2 objects results in only 1 score

For questions about using Classic.

Post » Sun Feb 05, 2012 11:59 pm

Hey everyone! This is my first post. I searched forum topics and did Google and Bing searches for the last 6 hours, or so, and can't seem to find any other reports of my problem. So I hope I'm not bothering anyone.

I am starting out with a simple Breakout clone. I followed the tutorial, here:

http://www.scirra.com/tutorials/46/introduction-to-families-for-construct-classic/page-1

It's a great tutorial and got me up and going. My problem is that my ball sometimes breaks two bricks, which isn't a problem while playing the game... but for some reason, even though both bricks get destroyed, you only get score for one, and my variable that calculates the end of the round only gets +1 added to it. So by the end of the bricks, the game is waiting for more.

I uploaded a cap to www.wlok.com/upload/breakout01.cap

Other than the double destruction, it seems to run pretty well.

Any help would be appreciated. And I'll keep trying other things. I read somewhere that I might not use the "Ball" object but I will need to read up on Custom Movement before I start that.
B
6
S
1
Posts: 21
Reputation: 617

Post » Mon Feb 06, 2012 1:51 am

I seems intuitive that it would add two.
First, one would assume that On Collision is a triggered condition, as most conditions begin with the word "On" are.

A green arrow appears before the condition name on the event sheet for triggered conditions:


in the screenshot below you can see this is not present on the On Collision condition.
Since the condition is not triggered by each collision, and instead is evaluated once in the order it appears in the event sheet. Those actions are carried out one time, regardless of the number of colliding instances, and all instances are picked at the same time. This is useful, because you can do things like make a sound play once even in the event of multiple collisions, instead of playing twice at the same time, etc,

If you need an action for each collision, you can still use a 'System: For Each Object' subevent to loop through each of the objects that are picked in the collision event - which results in the behavior you originally intended:



lucid2012-02-06 02:15:49
Spriter Dev
B
87
S
21
G
12
Posts: 3,240
Reputation: 16,461

Post » Mon Feb 06, 2012 3:30 am

Thank you so much lucid! I am trying to wrap my mind around why it would destroy the two blocks, but not score 2 blocks. Give me a little time and it will sink in to my brain. Hehe.

I understand your fix, tho. And that's the first time I've ever used a Sub-Event. I'm going to have to look at the manual for that specifically and learn more about them.

This worked perfectly and pretty much finished up the first board of the game. I really appreciate your help! I usually dish out hugs but I will get to know everyone better before that. Hehe.

Let me know if you'd like an exe of what I have so far. ^_^
B
6
S
1
Posts: 21
Reputation: 617

Post » Mon Feb 06, 2012 9:08 am

That was my first tutorial - glad it helped :)

@Lucid
Interestingly, I originally had the 'for each' condition but took it out after Ashley said I didn't need it, because the family inherrently used the for-each condition when checking.
If your vision so exceeds your ability, then look to something closer.
Moderator
B
120
S
28
G
68
Posts: 4,843
Reputation: 48,287

Post » Mon Feb 06, 2012 5:21 pm

This is something where C2 and CC currently differ, but hopefully will be fixed soon. C2 runs some sort of a loop when collisions happen based upon the number of instances involved.

http://www.scirra.com/forum/r75-loop-apparently-running-without-a-loop_topic48141.htmlArima2012-02-06 17:22:13
Moderator
B
87
S
32
G
33
Posts: 3,005
Reputation: 27,397


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 3 guests