Tower Defense

Get help using Construct 2

Post » Tue Jul 03, 2012 11:24 pm

Not sure the file you linked in your last post is the correct one.
It's no more a Tower Defense, it is a shooter.

Perhaps you should upload your capx to dropbox it's easy as managing its own hard drive.

As for your issue, you mention again that all instances of an object disappear when you use an action "Destroy".
I guess it is once again a picking problem.
You don't use conditions such that only the "current" instance gets picked and destroyed.
That's a guess without having seen the code though.

If I follow your logic correctly, once a TOWER is built, its BUILDSPOT is destroyed, so, logically, there should never be a TOWER overlapping a BUILDSPOT.

You can then use a subevent "BUILDSPOT is overlapping TOWER" and an action BUILDSPOT: Destroy

This will destroy any BUILDSPOT that has a TOWER over itself.

Have a close look at the topics listed in the how do I FAQ at the section "Picking/selecting instance(s)".

The subject is treated in many ways and with different approaches.
Hope it might help you.
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Posts: 6,938
Reputation: 56,920

Post » Wed Jul 04, 2012 12:12 am

Well you can look at my code but I finally got it fixed after I worked on picking the right item!!!

Now on to a more elaborate CONTEXT MENU for the Towers. Right now it is just a red BOX.. : )

It will eventually have several options such as Upgrade, Sell, Repair, etc.

Thanks for all of your help!
sparkdad2012-07-04 00:12:40
Posts: 50
Reputation: 1,228

Post » Mon Dec 31, 2012 6:19 am

Hi guys, I'm going to continue this thread here with my own "Tower Defense Context Menu" problems.

I have based my current context menu on sparkdad's design and am currently stuck at how to "Sell Towers". How to sell towers is really just a symptom of the larger issue being, "I'm not very familiar with the C2 UID & IID" and menus are currently not instanced contextual to what you've clicked. I've looked at the existing UID guides/tutorials but, they were hard to apply to this case. :(

I've made this capx to try and explain my problem. In this capx when you click to SELL it will obviously just sell ALL existing towers as it isn't discriminating between any of them yet.

Any help on how to differentiate between what you've just clicked and only apply changes to it using the UID (or better method?) would be much appreciated. ^^o
Posts: 12
Reputation: 901

Post » Mon Dec 31, 2012 6:59 am

What you need is to select one of the 'TerrainTowers'. If you do not specify any tower, the destroy command will be initiated on all of them. For this example adding a condition: Terraintower->pick closest (ButtonSellTower.X, ButtonSellTower.Y) at 'On touched $ ButtonSellTower' - trigger will fix your problem, it pickes the tower closest to the sell button being pressed. This could potentially be 'unsafe' way of doing things though if button happens to be closer to another tower than the one you are trying to sell.. :)

If that is the case, you'd need to save UID of the tower to sell button and pick the tower using the saved UID instead of closest to the sell button.vee412012-12-31 07:00:34
Posts: 756
Reputation: 7,192


Return to How do I....?

Who is online

Users browsing this forum: Mato, ozzmotor, Sup with that? and 6 guests