Let the player carry a value (money) from a object

0 favourites
  • 8 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • As the topic say, I`m wondering how I let the player carry a value from a object after the player has picket it up. Like in my Alex The Kid - In The Miracle World remake, I want to carry 1 coin from a money-object.

    I have tried to search the forum for a similar idea, but I only found

    this tread: scirra.com/forum/picking-up-coins-and-scoring-points_topic53475.html, but that didn`t worked.

    Heres my capx:

    dropbox.com/s/sakwfsv3hwe7itz/AlexTheKidInTheMiracleWorldRemake2.capx

  • You could just use an instance variable on your money object, have the player sprite check the value stored in it and then add that number to whatever variable holds the users current money total in the same event that is used to have the player pick up the object.

    For example:

    On player collision with money object - add moneyobject.value to player.currentmoney

  • So, I have to add a value to the money-sprite?

    And when the player collect the money-sprite the player-sprite need

    to figure out what value that money-sprite contains?

    Like as you said:

    On player collision with money object

    add moneyobject.value to player.currentmoney (Number which is money)

    Correct me if I`m wrong :)

    I also want to add that I want to have a text-box that shows how many moneys the player have picked up. Thanks for all your help so far!

  • add this as a second event to your "on pickup coin" code

    set textbox.text = player.currentmoney

  • I can`t figure out how to add

    "moneyobject.value to player.currentmoney"

    on the moneyobject. The . gives me a invalid-character when I

    add the codeline to the instance variable.

    BluePhaze: Did you had a look at my capx?

  • Your money object needs to have an instance variable called value, and the player needs to have an instance variable called currentmoney.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Aasmund I am at work right now, will have to wait till tonight. To get the . to work you need to first add instance variable to your money object, the same way you add behaviors. In the properties pain for your money object, click on add instance variable. Create one called value. On your character create an instance variable called currentMoney. Or just create a global variable called currentMoney. Then in your event when the player collides with the object just do the code like I have above, system add moneyObject.value to currentMoney. Then destroy the money object so you don't keep adding it over and over while the player is colliding with it.

  • Will try that to morrow. Have to get to bed, heading to work myself at 07:00 :)

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