[SOLVED] How do I make glow for batch buy buttons ?

Get help using Construct 2

Post » Thu Feb 08, 2018 10:47 pm

Hi,

I been trying to make batch buttons that will buy multiple upgrades at once when clicked like in here when there is enough cash to purchase them. I am trying to get them to glow by changing their animation to blue when there is enough cash.

Image

It's quite simple really. I want to use the same sprite for the buttons x5, x10, x20.etc with the number of times they need to run as it's instance variable.

But all of them are causing many types of errors. One time i got it right, all of them glow together as if the events ran only for the final one. Right now, it is however conflicting with the entire upgrade batch purchase eventhough otherwise it works fine.

The following are the events that i am using for it. I have disabled that in the project file attached and it just needs to be enabled to see the problem coming up.

Image

Image

Here is the attached project (.capx) file.

https://drive.google.com/open?id=1sSTsy ... 8Lj-k4bg2A
Last edited by Exion on Mon Feb 12, 2018 5:52 am, edited 2 times in total.
B
6
Posts: 11
Reputation: 258

Post » Thu Feb 08, 2018 11:18 pm

Hey @Exion,

its because the sub-events of the for-loop do not specify which button to turn blue. Right now it says: is there a button that matches the condition? -> turn each one blue.
Try this:

Image

I suggest to create another instance variable 'TotalCost' for your BatchBuyButton, so you dont need the division 'Cash/10'.
B
8
S
2
G
1
Posts: 79
Reputation: 1,404

Post » Fri Feb 09, 2018 4:39 am

You are trying to use "include" as a function or macro. That's not how include works. Copy the code in-place and you'll see it starts working better. Include is generally added at the top, once, which is like having that code all at the top of the same event sheet, running as if it was physically there.
ImageImageImage
B
71
S
22
G
273
Posts: 3,822
Reputation: 150,787

Post » Fri Feb 09, 2018 8:49 am

kriand wrote:Hey @Exion,

its because the sub-events of the for-loop do not specify which button to turn blue. Right now it says: is there a button that matches the condition? -> turn each one blue.

I suggest to create another instance variable 'TotalCost' for your BatchBuyButton, so you dont need the division 'Cash/10'.

It should purchase the upgrade 5 times with including the cumulative upgrade costs with x5. Each upgrade bought increases the upgrade cost by 10% by multiplying the previous upgrade cost by x1.1. So when it is clicked once while upgrade cost is 10, it will have the total cost of 10 + 11 + 12 + 14 + 15. Why i am not using a formula here instead is for both accuracy and to retain the accuracy for any new mechanics to be added so it will emulate to imitate the single click purchases done multiple times.

I have tried many methods including the one suggested right now but still i am very confused how the Include and Sprite operation priority works with conditions. The problem is likely with the Include itself. When the include is used even the batch button purchases are messed up eventhough on it works fine. When i include it for finding total upgrade cost for the glow, it gets messed up.

I have even tried this here with direct value comparison with 'else'. But when clicking batch buy button the upgrade costs are not working eventhough it should not be effected while trying to just do an animation change for a sprite.

Image

In this one, only x 5 glows and rest of them does not glow on top of messing the batch button purchases with the included event sheet to convert the cost. Problem is there with the way use 'include' too conflicting with other 'includes' which i would like to understand on top of this.

Here is the .capx project file for the above implementation.

BatchBuyTest2.capx
https://drive.google.com/open?id=1ps4DvNR4kWmN1dTgtfkPH4xtSN1rNlbi


It will be great if someone can correct it with an efficient example so i could understand. Eventhough that might be asking too much. I self-learned most of Construct 2.


blackhornet wrote:You are trying to use "include" as a function or macro. That's not how include works. Copy the code in-place and you'll see it starts working better. Include is generally added at the top, once, which is like having that code all at the top of the same event sheet, running as if it was physically there.

The Include and Event Sheets were used this way with the Repeat event in another event sheet to be copied to anywhere where i want to get total upgrade cost. It was used to create a temporary variable to find the total upgrade cost to be used for any operations. Instead the entire events should be copied to where ever it's required ? Is there any way to run the same events like Go To Events or run a group with a event link ?
B
6
Posts: 11
Reputation: 258

Post » Sat Feb 10, 2018 2:26 am

@Exion , here you go:
https://www.dropbox.com/s/982t5oiunhri3 ... .capx?dl=0

You don't really need the second event sheet, but I left it to demonstrate how to properly use "Include"
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :) If you'd like to hire me, please see this post
B
17
S
9
G
127
Posts: 1,761
Reputation: 67,843

Post » Sun Feb 11, 2018 5:58 pm

Thanks a lot. It's solved now. dop2000's example fully cleared it out and it was also educational and well laid out. Thanks a lot for everyone else's guidance too.
B
6
Posts: 11
Reputation: 258


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 25 guests