any precautions or suggestions for button clicking

goonergooner Lancaster, PAMember Posts: 135

say i have an upgrade that can be bought with 10 gold and each additional upgrade is +10 of the previous cost.

1) button displays cost of 10, click and get upgrade 1, gold reduces by 10
2) button now displays cost of 20, click and get upgrade 2, gold reduces by 20
3) button now displays cost of 30, click and get upgrade 3, gold reduces by 30
.... and so forth.

This currently works for me except when i start clicking the buttons really fast. I put the exact amount of gold needed into my table for testing and when following along slowly i will get all of the upgrades and be left with 0 gold.

However, when clicking really fast, sometimes I am left with extra gold, sometimes I run out before the upgrades are complete.

Please share any suggestions on button clicks...

also here are some specific quesions

  • use actor pressed or released
  • if i have an attributed "clicked" when do i set it back to false without messing up rules that use while click = true.

thanks for any advice!

Comments

  • NNterprisesNNterprises Member, PRO Posts: 387

    If you have anything in a rule or timer that says "Run to completion?" mark as TRUE

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited August 2016

    You didn't explain how you're doing all of that... what rules/behaviors... so it's hard to comment specifically. I would set it up this way:

    Display Text (game.upgrade+1) * 10
    When Touch is Pressed
         Change Attribute game.gold to game.gold-((game.upgrade+1) * 10)
         Change game.upgrade to game.upgrade+1

    If you aren't using a linear or geometric range of values, then a table would be needed instead of just multiplying by the upgrade value. What you want to avoid are rules that say When upgrade is 1, do this; When upgrade is 2, do this; ... because then Touch detection may occur during transitions (from upgrade 1 to upgrade 2... oh, now the touch/tap is still down and let's do whatever is in the upgrade 2 rule).

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    If that doesn't work for you then @BigDave is the king of clicker apps around here and can probably advise you better than me. :)

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    @ellison said:
    This currently works for me except when i start clicking the buttons really fast.

    These kinds of issues are very very difficult or even impossible to resolve if people can't see any of the rules being used.

  • AlchimiaStudiosAlchimiaStudios Member Posts: 1,069

    @ellison said:
    also here are some specific quesions

    • use actor pressed or released
    • if i have an attributed "clicked" when do i set it back to false without messing up rules that use while click = true.

    thanks for any advice!

    Released will check for a release state, press checks for initial button pressed. They can be used in conjunction to write code that will only re-trigger once released and then pressed again, which it sound likes is what you want to do.

    So rules would be something like:

    when touch is pressed and game.touched is false

    Change attribute gold to gold-10 (or whatever you wish to do)
    Change attribute game.touched to true

    when touch is released

    change attribute game.touched to false

    But it may be something else depending on how you have your rules set.

    Follow us: Twitter - Website

  • goonergooner Lancaster, PAMember Posts: 135
    edited August 2016

    thanks for all the replies,

    also, let me simplify since i am usually way too "wordy" ...

    the cost part on the button is working no matter what, i am only concerned with clicking the button and getting it to register as only one click until it's fully released ...

    i've just tried ...

    when touch is pressed and game.touched is false
    -do stuff
    -change attribute game.touched to true

    when touch is released
    -change attribute game.touched to false


    EDIT : working now .... touch outside set touch to false, and added touch inside to touch pressed and touch = false

    thanks again, much appreciated!

Sign In or Register to comment.