How do I add points to score in real-time without looping?

Get help using Construct 2

Post » Wed Nov 19, 2014 1:57 am

There are many "Bug" objects on the screen at the same time. When one of the "Bug" objects overlaps one of the "Wall" objects, 100 points should be added to the Points display in real-time. However, in my code, it continuously adds 100 points instead of just one time. I tried using a Trigger Once condition (see the second code). Thank you for your help!

This code continuously adds 100 points:
points.jpg

This code adds 100 points on the first overlap, but then continuously adds 100 points on other overlaps:
points2.jpg
You do not have the required permissions to view the files attached to this post.
B
7
S
2
Posts: 34
Reputation: 670

Post » Wed Nov 19, 2014 2:30 am

Try removing "For each" and leave trigger once while true - see if that helps.
B
10
S
1
Posts: 56
Reputation: 654

Post » Wed Nov 19, 2014 2:34 am

Use a collision event, not overlapping.

And for less code, put your wall objects in a family.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Wed Nov 19, 2014 4:08 am

Thank you for your help. I tried your suggestions along with many other things, but it's still not working exactly how I want it.

The points are being displayed, but they are cumulative, and I don't want that. For example, if there are three collisions on the screen, the points should be 300, and then later if there are two collisions on the screen, the points should be 200, not 500, which is what is happening now.

How do I make my points not cumulative?
points3.jpg
You do not have the required permissions to view the files attached to this post.
B
7
S
2
Posts: 34
Reputation: 670

Post » Wed Nov 19, 2014 4:23 am

Changing the on collision to to is overlapping then maybe a Else event that sets it back when not overlapping
B
42
S
17
G
2
Posts: 850
Reputation: 6,209

Post » Wed Nov 19, 2014 5:40 am

You need to reset global variable points then, you are now adding points to your overall number.
You can set something like "PointsPasser" as global variable.
PointsPasser will reset every tick, so it will pass the points on to main point global variable, set text to score and reset to "0" so it can show points from new collisions.
B
10
S
1
Posts: 56
Reputation: 654

Post » Wed Nov 19, 2014 10:05 am

If you could provide capx I might be able to help you
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,763

Post » Thu Nov 20, 2014 6:35 am

Lordshiva1948 wrote:If you could provide capx I might be able to help you


Here's a simple capx file.
All I want is when you move the Bug object (move it with arrow keys) over the Wall object, the Points are 100. When you move it off the wall, the Points go back to 0.
Thank you for your time and help!

points.capx
You do not have the required permissions to view the files attached to this post.
B
7
S
2
Posts: 34
Reputation: 670

Post » Thu Nov 20, 2014 9:18 am

DoomEyes you mean like this if not give me good explanation
You do not have the required permissions to view the files attached to this post.
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,763

Post » Thu Nov 20, 2014 9:24 am

DoomEyes could be like this
You do not have the required permissions to view the files attached to this post.
B
252
S
39
G
15
Posts: 1,964
Reputation: 40,763

Next

Return to How do I....?

Who is online

Users browsing this forum: Blendi1223, ditocruz, jatin1726, kiki4construct, Kyatric and 30 guests