Creating a coin counter

NmdogdudeNmdogdude Member Posts: 174
edited March 2012 in Working with GS (Mac)
I am trying to make a coin meter so that when the player touches a coin, the coin meter will go up +1

Can anyone help me with this?

Comments

  • LeonardDeveloperLeonardDeveloper Member Posts: 4,630
    edited March 2012
    set up an attribute called coin meter.. (integer)
    rule:
    in actor of coin:
    when touch is pressed change attribute to +1...
    ---------
    Have a separate actor.. a coin image... then but eth "replicate" behavior into the coin image and ask it to replicate the coin meter attribute..
    Here I made ya a cool template: http://www.mediafire.com/?9cr4j01y8mf14iq
    Thanks,
    Hope this helps,
    Jack
  • NmdogdudeNmdogdude Member Posts: 174
    edited March 2012
    Thanks, but how do I set up an attribute?
    Which actor should I set up the attribute in?
  • CloudsClouds Member Posts: 1,599
    set up an attribute called coin meter.. (integer)
    rule:
    in actor of coin:
    when touch is pressed change attribute to +1...
    ---------
    Have a separate actor.. a coin image... then but eth "replicate" behavior into the coin image and ask it to replicate the coin meter attribute..
    Thanks,
    Hope this helps,
    Jack

    I think when he says: "when the player touches a coin" he means "when the ACTOR touches a coin" . . . . ?
  • CloudsClouds Member Posts: 1,599
    Thanks, but how do I set up an attribute?
    Tell him you are just going to give him a package to take through customs, then run.
  • CloudsClouds Member Posts: 1,599
    In the Inspector - click on GAME - then attributes - then click the little '+' button in the bottom left hand corner.
  • NmdogdudeNmdogdude Member Posts: 174
    edited March 2012
    that's a cool template, but what I'm trying to do is that when a coin is collected on the game screen, then have a meter on the home screen get +1 each time a coin is touched by the actor.

    If that makes sense.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2012
    Use a replicate behavior. So basically, have game.coins increase by 1 and then have a separate actor (you can just make an actor say 10 x 10 pixels) that has a replicate behavior to replicate itself in a direction (e.g. 90° or whatever). The key is to make the copies value game.coins and the spacing value the width/height of the actor (10). I don't have GS open right now, but that's the idea. I have a video I can dig up (or you can Google "GameSalad health meter"). [Edit] here's my video... start at 3:46 to avoid unrelated content:



    Just realized other people already gave you this advice. What are you having trouble with?

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

  • NmdogdudeNmdogdude Member Posts: 174
    Well, this is my first time using Gamesalad and I'm still trying to learn what all the tools do.

    What I want to happen is that when the Coin actor is touched by the player's actor, then the # of coins on the homepage goes up +1

    BTW you guys have some awesome advice, but I'm not quite sure how to implement them in my project
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2012
    (1) Make a new game attribute called Coins. Set its initial value to 0.
    (2) In the Coin actor's rules, add a rule that says If actor overlaps or collides with Player then Change attribute game.Coins to game.Coins+1. Optionally, add a Destroy actor behavior.
    (3) Create a new actor called CoinMeter. Change its size to 20 width and 20 height. Choose a color for the actor. On the homepage, add the CoinMeter actor to the scene (for example, at the bottom near the center).
    (4) In the CoinMeter actor's rules, add a Replicate behavior with a direction of 0, copies equal to game.Coins (select this from the expression editor by clicking the small e button), and spacing equal to 20.
    (5) Preview your game, collect a few coins, and then take a look at the CoinMeter actor on the homepage to see if it has grown larger. If not, go back and add a Display Text behavior to the CoinMeter actor with Text set to game.Coins (again, use the expression editor). Be sure to set the text color to something other than the actor's color. Preview again, collect some coins, and check to see what number is appearing on the CoinMeter.

    If you still can't get it to work, tell me which numbered step above you don't understand and what happened when you tried that step. Also, how are you getting from the play scene (with the Player and Coins) to the homepage? Are you doing a Change Scene behavior, a Pause behavior, or a Reset Game behavior? And have you tried following the steps above but adding the CoinMeter to the play scene and seeing if it works correctly when your player collides with a coin? Finally, if you click on the Home button while editing your game, how many scenes do you have? What are they called?

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

  • NmdogdudeNmdogdude Member Posts: 174
    I can't get step 5 to work, When I have the player touch the coin, nothing happens to the meter on the home page.
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    edited March 2012
    I'm starting to lose patience with you. I know you're new to GameSalad, but I went out of my way to give you exact steps even though I knew that the videos that are available explain it even better. I'm still willing to help, but you need to do more than just say "it doesn't work." Can you answer the questions in the last paragraph of my post above? I specifically listed those because I knew that if you couldn't get it to work I would need to know the answers in order to help you further.

    You can also post a link to your game project file (use a Dropbox public link or mediafire or another upload site) so I can take a look at it.

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

  • NmdogdudeNmdogdude Member Posts: 174
    edited March 2012
    When I tried step 5, the player touched the coin and it disappeared like I wanted; but the coin meter on the home page didn't change.
    I have the "Start game" icon on the homepage with the "Change Scene" behavior set to the Game/play screen
    I currently have 6 Scenes (Title/homepage, Game screen, Options screen, Shop screen, Languages, and My items.
    And to get the "Display text" behavior visible, do I need to add a text box?
    Sorry if I got you frustrated, I'm just trying to get everything to work right. :)
  • MotherHooseMotherHoose Member Posts: 2,456
    changeAttribute for coinMeter has to be before the destroyBehavior

    the computer runs the rules/behaviors in a linear flow
    it will NOT process anything in an actor … after an actor us destroyed

    @};- MH
    "Games lubricate the body and the mind." — Benjamin Franklin
  • NmdogdudeNmdogdude Member Posts: 174
    How can I make the text appear?
  • NmdogdudeNmdogdude Member Posts: 174
    Here's the link to my project.
    /Users/timtoccalino/Desktop/DDS.gameproj
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Everyone here has told you exactly what to do. You should keep trying to do it yourself.

    Also we cant download a project off your desktop
  • NmdogdudeNmdogdude Member Posts: 174
    @ tatiang, thank you very much for helping me, I tried what you did and it worked, but the text is not visible.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    did you add the display text behavior?
  • NmdogdudeNmdogdude Member Posts: 174
    Yeah, but the text is not there
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    where did you add it? Is that actor in the scene? did you select the attribute to display?
  • NmdogdudeNmdogdude Member Posts: 174
    Wooohooo, I finally got it to work, (just had to change some rules around)
    THANK YOU EVERYONE FOR YOUR HELP AND BEING PAITIENT WITH ME :D
  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Congrats! As you'll see, this is a very helpful community, but you also have to take the initiative and just work through some of the challenges. Glad to hear it's working for you.

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

  • NmdogdudeNmdogdude Member Posts: 174
    Yeah, I guess I just have to do trial & error, and BTW great how you explained it to me step by step. I can't thank you guys enough!!
Sign In or Register to comment.