Scoreboard locked to the corner of the screen? (overlay?)

New releases and general discussions.

Post » Tue Oct 14, 2008 3:08 pm

Hi. I'd like to have a scoreboard for my game Move ( www.chrisalgoo.com ) in the upper-right, tracking time taken and deaths... died. Is there a way to have something overlaid on the action?
B
2
G
4
Posts: 12
Reputation: 1,074

Post » Tue Oct 14, 2008 3:44 pm

Create a new layer above the main one and set the ScrollX and ScrollY rates on said layer to zero. Then you can put all of your interface/scoreboard elements on that layer and they will be displayed above the action and they will move with the screen when scrolling. Hope that helps. :)
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692

Post » Tue Oct 14, 2008 8:39 pm

Thanks! Since I've already got a topic here, I'll use it to ask another question instead of creating a new one.

How can I create a timer? I want to increment a variable every 10 ms, and then display that on screen.
B
2
G
4
Posts: 12
Reputation: 1,074

Post » Tue Oct 14, 2008 8:44 pm

No problem. :)

For a timer, just a global variable for the timer. Then, for the on screen part, place a text object into your layout and always set it's text to the value of your timer variable.
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692

Post » Tue Oct 14, 2008 9:03 pm

The expression timer returns the time in milliseconds since the start of the layout. So timer / 10 will give you a value that increments 1 every 10 milliseconds. If you don't want all the decimal points, try int(timer / 10).
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,208

Post » Wed Oct 15, 2008 2:43 pm

So I can use timer in calculations, and it'll give me the time since the layout started? That's cool!

I have two questions about text, if that's cool.

1) How can I display variables in a text object? Everything I try just displays the variable name.

2) Is it possible to concatenate variables and nonvariables? I basically want to have a text object read Variable1.Variable2 , so I'd need to have a variable, a text thing, and another variable.


And one question that isn't about text

I want to use that timer that Ashley mentioned, and at the end of every level I'd like to write the value of Timer to a variable so that at the end of the game you can see all your times. Is there a way to dynamically determine what variable is written to (I guess this deals with concatenation as well). Like, if I have a variable called CurrentLevel that is currently set to 3, can I make it so that Construct will write to levelTime3? (or levelTime'CurrentLevel')?
B
2
G
4
Posts: 12
Reputation: 1,074

Post » Wed Oct 15, 2008 3:20 pm

1. To get it to display in the text box, try something like objectname('variablename') for private variables, just replacing object name and variable names with... well, the object name and the variable name. :P Then for global variables, use global('variablename').

2. Do this: object('variable') & "," & object('variable). The "&" will allow you to tack on extra parts to a string.

Hope that helps. :)
Moderator
B
97
S
36
G
19
Posts: 1,584
Reputation: 17,692

Post » Wed Oct 15, 2008 4:27 pm

[quote="ZeroFlowne":2ncepqo3]1) How can I display variables in a text object? Everything I try just displays the variable name.[/quote:2ncepqo3]
I bet you're trying stuff like:

"timer"

Stuff between quotes is constant text. Don't use quotes for variables:

timer
Scirra Founder
B
357
S
214
G
72
Posts: 22,946
Reputation: 178,208

Post » Wed Oct 15, 2008 5:10 pm

Don't I feel silly :D

Thanks
B
2
G
4
Posts: 12
Reputation: 1,074

Post » Thu Oct 16, 2008 2:56 pm

It still just has what i typed - currentLevel or timer or etc. Is there a different syntax for the Text object?
B
2
G
4
Posts: 12
Reputation: 1,074

Next

Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 4 guests