Display Score as Sprite

0 favourites
  • 14 posts
From the Asset Store
Make a displayed number gradually increase or decrease, making an impression of a real-time counting.
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I see, thank you~

    That's mean I can't upload the game into arcade~ ><

  • 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))

    AkiraWong

  • Thank you blackhornet

    This is very useful~ ^^

  • 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))

    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?

  • SpriteNumbersScore.capx

    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?

  • 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

  • ... 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..

    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

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

    SpriteNumbersScore2.capx

  • That looks awesome! How come you changed it from using frames to using separate animations for each number? Also, it would be cool to set the sine position to 0 after the numbers have all resized, but when I try that, it just ends up making all the numbers squash and stretch in unison (rather than the way you have done it where they move independently) or they don't cycle at all?

  • korbaach quick question, how can I modify this by breaking the digit spacing up for a timer? If I wanted, say 0:00:0 unit display, and I wanted to separate the digits with a gap between digits 1 and 2, no gap between 3 and 4, and a gap before 4 and 5, how could I do this? I would also need to have the numbers represent a minute/seconds/nanoseconds format and, while counting down should be easy, I'd need them to represent the figures correctly. Do you have any suggestions?

  • For instance:

    How can I run a countdown timer into the sprites, with separation marks?

  • I did it with three copies of the sprite and the events, separated by a static colon sprite, then I just count like so:

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)