Coin gives twice it's correct score

For questions about using Classic.

Post » Sun Feb 07, 2010 9:21 pm

I am working on a simple platformer and at first the coins/score worked fine, but all of a sudden each coin started giving 20 points instead of 10. I notice that it quickly changes from 0 to 10 to 20 when I pick up the first coin (if I write it a way that makes the score changing slower). This means it is adding 10 points TWICE for each coin.

I have this for the score/coin system:

Always - Score: Set text to PlayerModel.Value('Score')
On Collision between PlayerModel and GoldCoin - GoldCoin Destroy, PlayerModel: Add 10 to 'Score'

I have tried a lot of different combinations of things, including Is Overlapping, but no matter what I do, it always gives 10 points twice. I even made a new object to replace the coin, but it doesn't work either.

=/ Help please!

Edit: For my level I am using Included Event Sheets and a seperate event sheet for some stuff. When I put that event on the linked event sheet, it works right! Does that mean there's something wrong with the event sheet?
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Sun Feb 07, 2010 9:25 pm

strange, if its On Collision it should work, specially if you're destroying.
Make sure you're not also adding 10 elsewhere

you could post the .cap file so someone can take a look at it
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Sun Feb 07, 2010 9:26 pm

Can you post a .cap showing this happening?
Scirra Founder
B
359
S
214
G
72
Posts: 22,952
Reputation: 178,580

Post » Sun Feb 07, 2010 9:28 pm

Do you have a duplicate event somewhere? Have you tried adding a "Trigger Once While True" to the event?

A .cap would help especially since you said it worked fine at one point.
B
8
S
3
G
7
Posts: 835
Reputation: 5,313

Post » Sun Feb 07, 2010 9:34 pm

Have you by any chance accidentally placed two coins right on top of each other?

Also, delete every coin except one, then run the debugger. See if it only shows one instance in the debugger or if there is more than one instance.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sun Feb 07, 2010 9:41 pm

Actually, if I change the coin value to 5, it gives 5 points twice. Even if I disable every other event in that event sheet, it still does it. If I put that command on another included event sheet, it starts working correctly...

Edit: I already checked for multiple coins. I had even created a whole new object to perform the same thing and it had the same problem.
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Sun Feb 07, 2010 10:01 pm

I found the problem! I had two Event Sheets included:

Color Select Event Sheet
and
Main Event Sheet

The problem was that Color Select Event Sheet INCLUDED the Main Event Sheet too. So it was running the event sheet twice! It worked fine at first until I started testing something in the Color Select Event Sheet and therefore Included the Main Event Sheet in it for the testing.

BTW, I found this by randomly deleting things...

Edit: So even if I tell an Event Sheet to trigger something only once (which I tried too), but load the same Event Sheet twice (unknowingly in this case), it will trigger the same event twice.

I wonder if this would happen if I used Inclue Even Sheet twice in the same layout, or only if the second Include was in another Included sheet. Interesting...
B
2
S
2
G
2
Posts: 372
Reputation: 1,794

Post » Sun Feb 07, 2010 10:17 pm

[quote="Mr Wolf":3ekxzneb]I found the problem! I had two Event Sheets included:

Color Select Event Sheet
and
Main Event Sheet

The problem was that Color Select Event Sheet INCLUDED the Main Event Sheet too. So it was running the event sheet twice![/quote:3ekxzneb]

Ah, I had a feeling it was something simple like that :). Glad you got it all sorted.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests