scoreboard

Get help using Construct 2

Post » Sun Jun 10, 2012 12:41 am

to show the score in 1 textbox, I can use a global variable.
To show 2 scores (create a scoreboard), I suppose I can't use 2 global variables so I created 2 distinct variables in 2 different objects and created an event, on collision, add 1 to textbox (variable name) and with event system, every click, set text to "& variable name" but this doesn't work. Putting & variable name outside the " " doesn't work either. how can I fix this? The goal is to create a scoreboard.

https://dl.dropbox.com/u/26331535/test.capx
Ratboy2012-06-10 00:42:12
B
15
S
3
G
4
Posts: 11
Reputation: 2,726

Post » Sun Jun 10, 2012 3:59 am

Why are you using a textbox to display text? It is used to enter text, for example to get player's name. Notice that you can click with the mouse inside the textboxes and they get focus so the player could change the score. I don't think that is what you want.

Normally you'd use the Text plugin, which is in the same group as Sprite.

Then if you want to display more than one value in the text object, do something like:

Text.Text-> "Home: " & Score1 & NewLine & "Away: " & Score2

Where Score1 and Score2 are global variables (although you could use two instance variables created on the text object, which would be referred to as Text.Score1 and Text.Score2.)

I put these change in your project.

While I don't think you'll be using them, I modified your textboxes since they had several problems. (They are hovering up in the sky for now.) The instance variables were type Text, so you couldn't add to them. This is what was giving you big problems, I think. I don't know why it wasn't generation an error. Something to look into. (EDIT: I checked and Add to for a string concatenates to the end of the string.) Anyway, I changed them to numbers and the addition works fine. Then to modify the text of the textbox you were doing strange things with the locations of the quotes relative to the variable names and the & (I think because you couldn't get anything to work.) Also you only need to set the font properties once, so I moved that to on start of layout, instead of every tick.



Here is the modified project.

TestScoreBoard.capx

Looks like it will be a fun game.kittiewan2012-06-10 04:27:55
B
29
S
11
G
12
Posts: 281
Reputation: 11,878

Post » Mon Jun 11, 2012 12:09 am

thx!!
B
15
S
3
G
4
Posts: 11
Reputation: 2,726


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 20 guests