score box

Get help using Construct 2

Post » Tue Dec 17, 2013 3:10 am



I'm building a simple one level platform jumper for my first game. I have turrets firing at the player and a wall at the end of the map. The player scores one point every time the jump into the wall. One hit from a turret kills the player.
Anyways I have a array set up to generate 1 point every time player collides with the wall. I don't know how to cause the array's value to be put into the text box.
B
2
Posts: 4
Reputation: 158

Post » Tue Dec 17, 2013 4:24 am

ok so now I have a array called score set up. Everytime player has collision with finish. finish is a block at the end of the map. score gets +1.
Also have a txt box set up called score. add 1 to score is set up under the same collision command as above. I can see the txt box at the end of the level. But a score is never added to it.
B
2
Posts: 4
Reputation: 158

Post » Tue Dec 17, 2013 4:48 am

added a array to the container property of txt box, still wont display score of game.
B
2
Posts: 4
Reputation: 158

Post » Tue Dec 17, 2013 6:09 am

have you considered using a global variable instead of an array?
thats what Im using on "Untitled"
you set the GV to 0 and everytime the player touches the wall have it add one to the GV. the GV will persist until the game closes or you call a reset on the GV. then you can use a normal text event instead of a textbox and do a replace with something like "Score: " & Player_Score
B
3
Posts: 4
Reputation: 183

Post » Tue Dec 17, 2013 7:08 am

Using a global variable would probably be best here, but if you want to use an array it would be something like this:

player on collision with finish
trigger once
-array set value at 0,0 : array.At(0,0)+1

system every tick
text set text : "score: "& array.At(0,0)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Tue Dec 17, 2013 3:21 pm

I went with the global variable. Took me some time to figure out where to declare a global variable at. But the box now add's to the score correctly. Thanks.
So I take it the array is better used for multiple values. For example player 1 to 4's score and other constant numbers?

Anywho this puts my first game nearly done. It's sooo bad. But I learned alot of useful stuff. Thanks.
B
2
Posts: 4
Reputation: 158


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests