How do I gradually increase the Numbers in text?

  • Guys, so for example we have a text of 10 and if i click a sprite the 10 should increase to 15. but not immediately, it should increase like 11,12,13,14,15 . Any ways to achieve this, thanks.

  • Lots of ways to achieve this. You can start a Timer and every On Timer event increase your text by 1 until it =15.

    Or you can use Sine or LiteTween behavior with "Movement=Value". On "Sine->Is Active" event change your text with the Sine.value

    I recommend LiteTween behavior, you can make cool speeding/slowing down effects.

  • i tried what you said using the LiteTween behavior but it seemed to have random numbers in decimals, could you perhaps help me out with the exact events . Thank you.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • This will change text from 10 to 50 with slowing down effect.

    Here you can see how all LiteTween functions work:

    http://easings.net/

  • yes i tried this logic out and after it hits 50 it goes back to 0, what seems to be the error here, Thanks

  • Hey sublimate!

    The capx below shows a simple step-by-step increment. Every time you click the button it will add 5, 1 by 1, to the number. You can set the total increment and the speed by changing instance variables totalIncrease and increaseInterval respectively.

    https://www.dropbox.com/s/ipp9peqinp4o5 ... .capx?dl=0

    Hope it helps. Cheers!

  • yes i tried this logic out and after it hits 50 it goes back to 0, what seems to be the error here, Thanks

    You did something wrong (probably set Start Mode to "Ping Pong").

    Just copy tween settings from my screenshot, they work correctly.

  • yes it works right in a test variable, however the "Target " has been pre-set to 40 whereas i need it to be dynamic and needs to increase by 5 with each click.

  • You can set/change the Target and all other settings for the LiteTween with events. It's a powerful behavior once you learn how it works.

  • I understand you want to animate your scores?

    I made a small demo:

    Tween Demo

    CAPX

  • I understand you want to animate your scores?

    I made a small demo:

    Tween Demo

    CAPX

    you could achieve the same thing with distance(score,0,rewardedtobeadded,0)/10 i think.

  • gamecorpstudio

    I don't get it..

    If initial score=500 and I want to add 20, then distance(score,0,rewardedtobeadded,0)/10=48

    What should I do with this number?

  • gamecorpstudio

    I don't get it..

    If initial score=500 and I want to add 20, then distance(score,0,rewardedtobeadded,0)/10=48

    What should I do with this number?

    let me do a capx il edit here ! better to show then tell.. i know the math sounds weird but works from what i tested on other projects using that "formula" for easy incrementals.

    Edited (2 minutes later) : as promised now the division is value "20" not "10"... "10" was what i used for movement but is basically the same formula.

    The so called "formula" it's actually a sort of a no sort of a % comparison of the two numbers no matter what the number is... the increment is always going to be accurate. it's either how is supposed to work or is a C2 glitch... however this is how i always used it... if it's going to change in any update soon... i want to keep this C2 version lol. makes life easier.

    i hope it's helpful and you ( sublimate or who might need it) cut off the extra plugins that might cause problems in mobile compilations. im pretty sure this method works with C3 also as long as you have the expressions there. capx incremental number using distance

    to get the exact ease-in incremental just increase the divided" %" or the value "20" to "30" or "40".

    extra perk "no custom plugins" and works with any number.

    known issues, you might need an boolean/variable/trigger /condition whatever you might call it, to detect when the increment is happening so you dont double time reward if you multi click it(thats if will be triggered by click). if it's only triggered at end of round or achievement or reward for destroying something or collecting some coins then there is no need for extra conditions just copy paste it(make sure you got the global variables in your capx when you transfer and add the "trigger one time" properly).

    @sublimate check the capx above maybe is a better alternative for what you want.

  • gamecorpstudio thanks for the detailed explanation and demo! Although this method has some limitations comparing to tween behaviors, it's definitely useful.

    This formula appears to be similar to "easind Out" tween function, can it be modified to simulate "easing In"? (slow at the beginning, gets faster at the end)

  • gamecorpstudio thanks for the detailed explanation and demo! Although this method has some limitations comparing to tween behaviors, it's definitely useful.

    This formula appears to be similar to "easind Out" tween function, can it be modified to simulate "easing In"? (slow at the beginning, gets faster at the end)

    that can happen if you decrease the / number while dividing it so you start with a division by 100 let's say, and then every 0.01 subtract 1 from that 100 and the reversed incremental should appear like that "easing in". -Edited: scratch that ... im working on it, the distance adding is automatically doing its own easing out effect cause the distance is always shrinking, so what would make sense after a surtain number the distance to be at a surtain number that creates the illusion of fastening up. its definitely doable but im not sure if distance would work for the reversed effect.

    Honestly i never used the tween plugin didn't found it useful for my own, it's definitely a interesting plugin and helps a lot of people just i think it's an extra dependency that is not really needed once you know C2 expressions. i guess for desktop targeted games wont cause problems the plugin itself but some compilers for mobile will probably have issues with it, if not now in future for sure, unless it's updated by the dev.

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