How do I multiply instance variables

0 favourites
  • 5 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • My game is a mining game. When I have Gold bars I want to sell them to a trade shop in return for money.

    I am using instance variables so when I transfer my "Gold Bar instance variables" to "Amount of money instance variables" it will change "10 Gold bars Instance variables" to "10 Amount of money instance variables"

    I need it to change from "10 gold bars" to say "100 amount of money" so how can I make the instance variables multiply with each other?

  • If you are trying to set the amount of money after the purchase:

    Add action > system > Set value. On variable you set the amount of money and the value I dunno, set it to amount of gold * 10 or something. It depends on how you want the transaction to work.

    If the player already have some money, use Add value instead. Add to the amount of money the amount of gold times something.

  • Would this work?

    sprite set variable amountofmoney : 10*sprite.GoldBars

  • Create objects of gold bars, sprites, so each sprite representing each gold bar there will be an instance of gold variable name, this for each gold bar representing certain amount of money. Create a global variable name of money then multiply the values of the corresponding gold bars for 10 and assigns the variable money to this value.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I added the *10 to the end and it worked.

    Event: "Mouse click on shop" Add Action: "Amount of money Instance Variables" Add to "Gold Bar Instance Variables*10"

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