How do I Upgrade My Turrets

Get help using Construct 2

Post » Tue Nov 25, 2014 10:59 pm

Hey guys thanks for your help over the past few weeks.
It's been 3 Weeks I discovered Construct 2, and I've done things I wouldn't even think possible in such a short time.
So, 400 events laters I am stuck again.

I've been making a rather complex turret defense game and other details aside, I am stuck on upgrading turrets.

I want:
1. Each instance of a turret to be upgraded individually on mouse click

My Thought process:
I want so that on click of a turret instance, an "upgrade" button becomes visible. Clicking on this button, the turret instance variable, "TurretLevel" is incremented by 1. Then, the projectile sprite instance variable, TurretPower is calculated as TurretPower= (TurretLevel+1)^2. Then when projectile overlaps my enemy sprites, TurretPower is subtracted from EnemyLifePoints. When EnemyLifePoints is lessthan or equal to 0, it is destroyed.

My problem:
I can't find a feature that lets me obtain the identity of a single turret instance just be clicking on it.

It's easy to upgrade all turrets at once using pick all, and I can't specify the exact instance because it doesn't mean it's the right one.
Last edited by nzhu on Tue Nov 25, 2014 11:06 pm, edited 1 time in total.
B
4
Posts: 17
Reputation: 234

Post » Tue Nov 25, 2014 11:05 pm

HI @nzhu I needed to solve this for myself recently. I created an instance variable and set an identifier for each instance.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Tue Nov 25, 2014 11:14 pm

In order to pick a single instance is Construct2 you need to reference it in the conditions portion of an event.
If you use on-mouse-click instance type the specific instance you click on will be "selected", you would then have your event continue on to modify the instance variables of the selected instance via sub-conditions/actions attached to the same On-click condition... of course each instance will have to have all the necessary instance variables
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
65
S
17
G
8
Posts: 636
Reputation: 9,333

Post » Tue Nov 25, 2014 11:23 pm

hundredfold wrote:HI @nzhu I needed to solve this for myself recently. I created an instance variable and set an identifier for each instance.



Ohh Nice idea!

So If I understand you correctly, you essentially mean this,
1. Create object
2. When object is created, for example add 1 to an instance variable, Identifier
3. Choose event, "On left mouse click on Turret" && "Identifier = 1" (or 2,3,4 depending on the number of turrets made)
4. Add an action, Add 1 to Instance variable TurretLevel
5. Now, only the selected turret witch matching Indentifier will have the level of the turret upgraded.

I haven't tried it yet, but that's my new logic.
Does it seem reasonable?
B
4
Posts: 17
Reputation: 234

Post » Tue Nov 25, 2014 11:32 pm

chrisinfinger wrote:In order to pick a single instance is Construct2 you need to reference it in the conditions portion of an event.
If you use on-mouse-click instance type the specific instance you click on will be "selected", you would then have your event continue on to modify the instance variables of the selected instance via sub-conditions/actions attached to the same On-click condition... of course each instance will have to have all the necessary instance variables


Thanks for reponding.
Yes that is what I am trying to do.
I am confused on how to reference the specific instance that is being clicked on.
I don't think I can't use a specific instance (like Pick nth Instance) = 0 or 1 or 2 etc since turrets will be spread all over the map and so I can't just pick any single one without any way to identify that specific instance.....
B
4
Posts: 17
Reputation: 234

Post » Tue Nov 25, 2014 11:34 pm

It was a little different for my application but it looks like you're along the right lines.

In fact, in your instance you might want to use 2 instance variables, one to identify the specific turret and the other as a record of the upgrade level for each turret.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560

Post » Tue Nov 25, 2014 11:44 pm

hundredfold wrote:It was a little different for my application but it looks like you're along the right lines.

In fact, in your instance you might want to use 2 instance variables, one to identify the specific turret and the other as a record of the upgrade level for each turret.


Cool.

Now, I just realized a problem.
The identifier is a set part of the event condition.
That means that I'll need to make as many events as there are identifiers.
What if someone made 100 turrets? That means I'll have to make 100 events. One event for each instance.

For example:
Event 1:On left mouse click on Turret" && "Identifier = 1
Event 2: On left mouse click on Turret" && "Identifier = 2
Event 3: On left mouse click on Turret" && "Identifier = 3
.
.
.
Event 100: On left mouse click on Turret" && "Identifier = 100

Is there an easier way to consolidate the 100 turret instaces = 100 events into a few events?
And I have 12 different turret types, 6 for player 1 and 6 for player 2....sooo if I do it this way, I'll end up with like 1200 events.
B
4
Posts: 17
Reputation: 234

Post » Wed Nov 26, 2014 12:16 am

You could do a "For each" loop on the object, check for mouse click and then use the variable in your action.
Image
B
9
S
3
G
1
Posts: 346
Reputation: 1,560


Return to How do I....?

Who is online

Users browsing this forum: Sparkz and 3 guests