Add A Counter Every Time I Jump?

Discussion in 'How Can I...?' started by Dean Taylor, Apr 30, 2020.

  1. Dean Taylor

    Dean Taylor Boxer

    Joined:
    Apr 29, 2020
    Messages:
    12
    Likes Received:
    2
    I have limited my character to only have 7 jumps, when my character touches a platform they get another 7 jumps.. I'm trying to add a visual counter so when somebody plays my game they know how many jumps they have left before the hit the ground..

    I nearly got it by using the add point node attached to my touch node then I use the if collide node to reset the counter when I collide with a platform. Then in my UI I used default font, event observer and configure it for total points, session limit set to 7.

    Doing it this way nearly works for what I want, except because I have the add point node attached to my touch node to count the jumps the counter goes beyond 7 if the touch in game is repeatedly pressed..(see screen grabs)

    I hope this makes sense. Basically I just want a visual in game jump counter so player knows how many jumps are left before they hit the ground.. Thanks for your help.
     

    Attached Files:

  2. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    If I understand this correctly, does the counter start at zero and count to 7, rather than starting at 7 and counting down to zero?

    In either case, I would not use Add Point. After the Touched Press I would add a custom script node which checks if a variable in that custom script node is higher than 0, perhaps called jumpsRemaining (counting down from 7 would be better than counting up to 7 I think). You could subtract 1, and then set the text of your UI label to jumpsRemaining. The Jump and Sound nodes would be attached to the custom node, and only trigger if jumpsRemaining is higher than 0.

    After the platform collision, you can send a signal to the custom node to set jumpsRemaining to 7.
     
  3. Dean Taylor

    Dean Taylor Boxer

    Joined:
    Apr 29, 2020
    Messages:
    12
    Likes Received:
    2
    Thanks so much for your reply. Customer script is a bit too advanced for me at this time as I've only been using for 2 weeks so I'm still a noob at the moment.. I will use your feedback and research on how to do it, hopefully I can figure it out..

    Thanks again for taking the time to reply.
     
    sws likes this.
  4. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    I looked again, and I think I might see the problem. On your nodes you have been using Coins, so on the Event Observer in your UI, you must change the Event Type to Session Coins.
    Alternatively, if you want to use Points instead of Coins, you will have to change your Add Point node and UI Label to Points instead of Coins.
     
  5. Dean Taylor

    Dean Taylor Boxer

    Joined:
    Apr 29, 2020
    Messages:
    12
    Likes Received:
    2
    Thanks again Mate. I'll give it a try and let you know. Thanks again so much for your help.
     
  6. Dean Taylor

    Dean Taylor Boxer

    Joined:
    Apr 29, 2020
    Messages:
    12
    Likes Received:
    2
    I tried it mate but it's a no go, it's still counting beyond 7. I thought that by setting the session total to 7 it wouldn't count beyond that number..
     
  7. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    I'm not sure why it isn't working for you, maybe change your Add Points node to Global instead of Local. I made a simple game if you want to take a look at it, in this case the ground counts as the platform which resets the jumps to zero. I tried to upload the Buildbox file on here, but it tells me that type of file isn't allowed (hmmm...)
    Here is a link to the project file: https://easyupload.io/7a8hvj

    jumptest1.png jumptest2.png jumptest3.png jumptest4.png
     
    Last edited: May 4, 2020
  8. Dean Taylor

    Dean Taylor Boxer

    Joined:
    Apr 29, 2020
    Messages:
    12
    Likes Received:
    2
    Thanks Mate for all your help. I see why yours is working and mine isn't. You have made your event observer to end the game after 7 jumps. I wasn't wanting the game to end but carry on.. I only want the counter to indicate to the player how many jumps they had left before they need to touch the platform not to restart the game once the jump limit has been reached.

    I'm starting to think it isn't possible with out some custom code.

    I really appreciate your help and your time.. If you have anymore ideas please let me know.. Thanks again mate..
     
  9. sws

    sws Boxer

    Joined:
    Apr 20, 2020
    Messages:
    26
    Likes Received:
    6
    Oh haha sorry I thought the game ended after there were no more jumps. I changed Add Point to custom code which uses a variable. I set it up to still change the Coin Amount and display the Coin Amount (because I am still figuring out how to find a label to set the text...)

    Link to new build: https://easyupload.io/00ax0p

    Edit: In the code, you can delete:
    this.scene()['resetCoins'](true);
    this.scene()['addScoreCoin'](Settings[jumpNumber]);

    and replace it with: this.scene()['addScoreCoin'](1);

    You can also delete these lines, I forgot to remove them:
    let callNameReset;
    let callNameAdd;
    let arg;
    let amount;

    jumptest1.png
     
    Last edited: May 5, 2020
    Dean Taylor likes this.
  10. Dean Taylor

    Dean Taylor Boxer

    Joined:
    Apr 29, 2020
    Messages:
    12
    Likes Received:
    2
    I needing a way
    Mate Thanks so much for taking your time to help me, your so kind. I'll download the new build now and have a play. I'll let you know how it goes. Thanks again mate.
     
    sws likes this.
  11. Dean Taylor

    Dean Taylor Boxer

    Joined:
    Apr 29, 2020
    Messages:
    12
    Likes Received:
    2
    sws this worked great, thanks again for all your help... it was exactly what I was looking for..
     
  12. Dean Taylor

    Dean Taylor Boxer

    Joined:
    Apr 29, 2020
    Messages:
    12
    Likes Received:
    2
     

Share This Page