Display Score as Sprite

Get help using Construct 2

Post » Sun Aug 19, 2012 1:10 pm

Hi,

Actually I'm testing a long time about this question and searching for manual and FAQ but haven't found the answer yet so I decided to post a topic here.

The common way for displaying score is print the text out. But I have my own stylish 0 to 9 sprite images. How do I display those images like the print text function?

Appreciated,
Thanks.
B
13
S
5
G
3
Posts: 63
Reputation: 3,989

Post » Sun Aug 19, 2012 2:01 pm

Use this SpriteFont plugin :)
http://www.scirra.com/forum/plugin-spritefont-31th-july-2012_topic45876.html
B
36
S
10
G
6
Posts: 960
Reputation: 11,125

Post » Sun Aug 19, 2012 4:49 pm

I see, thank you~
That's mean I can't upload the game into arcade~ ><
B
13
S
5
G
3
Posts: 63
Reputation: 3,989

Post » Sun Aug 19, 2012 5:19 pm

Here's a simple trick for scores:

Create a global variable: Score

Load your ten numbers (0to9) as sprite frames (name: ScoreSprite). Give your sprite an instance variable, 'index'. Place, let's say, four instances. Give the 'index' values 0 to 3. Use this line:

Every Tick -> ScoreSprite -> Set animation frame to int(mid(str(zeropad(Score, 4)), ScoreSprite.index, 1))

@AkiraWongblackhornet2012-08-21 19:21:01
ImageImageImage
B
71
S
19
G
157
Posts: 3,395
Reputation: 91,436

Post » Tue Aug 28, 2012 4:54 pm

Thank you @blackhornet
This is very useful~ ^^
B
13
S
5
G
3
Posts: 63
Reputation: 3,989

Post » Tue Dec 15, 2015 2:43 am

blackhornet wrote:Here's a simple trick for scores:

Create a global variable: Score

Load your ten numbers (0to9) as sprite frames (name: ScoreSprite). Give your sprite an instance variable, 'index'. Place, let's say, four instances. Give the 'index' values 0 to 3. Use this line:

Every Tick -> ScoreSprite -> Set animation frame to int(mid(str(zeropad(Score, 4)), ScoreSprite.index, 1))

@AkiraWongblackhornet2012-08-21 19:21:01


Trying this out, but the parser is telling me this it requires a string not a number where the 4 is. Has anything changed since this was written?
B
37
S
11
G
10
Posts: 973
Reputation: 8,949

Post » Tue Dec 15, 2015 3:17 am

Image
B
58
S
23
G
7
Posts: 1,437
Reputation: 10,553

Post » Tue Dec 15, 2015 12:46 pm


Thank you so much! Is there a benefit to using this method over sprite fonts? Also, why is the score global passes to a text object first instead of directly to the sprite count?
B
37
S
11
G
10
Posts: 973
Reputation: 8,949

Post » Tue Dec 15, 2015 1:38 pm

Here, I updated it to include an additive score that gradually increases. Just add to the Score variable and ignore the ScoreCount variable since that's there to act as a mid-way. Change the seconds count to taste. https://www.dropbox.com/s/st3ssvoth4qvj ... .capx?dl=0
B
37
S
11
G
10
Posts: 973
Reputation: 8,949

Post » Tue Dec 15, 2015 2:28 pm

Zebbi wrote:... why is the score global passes to a text object first instead of directly to the sprite count?

@Zebbi you dont need text object..i put text in example ..just to debug sprite frames..
Zebbi wrote:Is there a benefit to using this method over sprite fonts?


if you want to use behaviors ..(like Sine) ..I think it's better touse Sprite object..
also you do not have to use only one frame per number..you can use animation

Image

(in example i just draw some random spots (a0&a5)..but of course, ....sky's the limit :) )

SpriteNumbersScore2.capx
Image
B
58
S
23
G
7
Posts: 1,437
Reputation: 10,553

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 3 guests