How do I function to buy upgrades in game

Get help using Construct 2

Post » Mon Sep 07, 2015 12:04 am

Hello, can you help me?
I want to build a function to buy "speed" in my game.

I did so:
1- created a global variable called money, it starts with 100, (just for testing)
2- created a function called buy
3- created a button named "btn_speed_up", that button added an instance variable named cost with the value of "speed", 85 (cost for upgrade)

As did the code below:

Image

Image

Does not work. Nothing happens, can anyone help?

Thank you =)
B
25
S
4
G
2
Posts: 99
Reputation: 2,498

Post » Mon Sep 07, 2015 12:08 am

I did some tests and everything seems to work fine. Can you post a capx or more code? Also, your Else statement will never be called.
B
56
S
15
G
13
Posts: 826
Reputation: 17,705

Post » Mon Sep 07, 2015 12:44 am

I isolated the game and still does not work =/

capx:
https://dl.dropboxusercontent.com/u/206 ... -test.capx
B
25
S
4
G
2
Posts: 99
Reputation: 2,498

Post » Mon Sep 07, 2015 12:59 am

The initial value on your speed_up variable is set to 100 :) You also need to change the Greater Than to a Less Than, in your Buy function.
B
56
S
15
G
13
Posts: 826
Reputation: 17,705

Post » Mon Sep 07, 2015 1:11 am

Yes, I need more coffee =P
But see, the variable "speed_up" does not change value. It seems that he does not read the function.ReturnValue
B
25
S
4
G
2
Posts: 99
Reputation: 2,498

Post » Mon Sep 07, 2015 3:44 am

Here, I fixed everything. Notice the new instance variable.

http://s18.postimg.org/tohskwt3d/Help024.png
B
56
S
15
G
13
Posts: 826
Reputation: 17,705

Post » Tue Sep 08, 2015 12:02 am

thank you for help. But my variable "speed_up" yet increases. You saved the .capx? Mine is equal and does not work @ _ @

Thank you again.
B
25
S
4
G
2
Posts: 99
Reputation: 2,498


Return to How do I....?

Who is online

Users browsing this forum: Semoreh and 7 guests