Tower Defense Forum Home > Construct 2 General > How do I....? |
Post Reply
|
Page 12> |
| Author | |
Post Options
Quote Reply
Topic: Tower DefensePosted: 31 Dec 2012 at 6:59am |
|
|
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. Edited by vee41 - 31 Dec 2012 at 7:00am |
|
![]() |
|
Post Options
Quote Reply
Posted: 31 Dec 2012 at 6:19am |
|
|
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. https://docs.google.com/open?id=0BwpJP16ac7kcUGJCb2NXN0NjNGM 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 |
|
![]() |
|
Post Options
Quote Reply
Posted: 04 Jul 2012 at 12:12am |
|
|
https://docs.google.com/open?id=0B5puA55FudSeSEJfc001NWp2Yzg
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! Edited by sparkdad - 04 Jul 2012 at 12:12am |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Jul 2012 at 11:24pm |
|
|
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. |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Jul 2012 at 9:43pm |
|
|
UPDATE #2
DID NOT WORK!!!! I think that I am going to rewrite and use animations for the rollover to take the complication out of some of this. I will note when done. Edited by sparkdad - 03 Jul 2012 at 11:01pm |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Jul 2012 at 9:01pm |
|
|
Another problem!!!!
Now I am creating the Context Menu at build spots. When you mouseover a build spot it highlights. Once you click it a red box pops up that will eventually contain towers that an be built. When you click on the red box ( or eventually icons of towers ) it should build a tower on the BUILD SPOT that was originally clicked. This is working fine. When the event is OVER it should get rid of the BUILDSPOT that the tower was built on : ) but it gets rid of ALL of the build spots! Thought? https://docs.google.com/open?id=0B5puA55FudSebWFFRUt2T1p4VG8 |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Jul 2012 at 3:57pm |
|
|
Awesome! Thank you! I am getting better at Construct Events but still have some work to go! I appreciate the communities help!
|
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Jul 2012 at 3:33pm |
|
|
Actually, when you set your action "Destroy lifebar" atm, it picks all lifebars of all enemies.
To correct : Add an instance variable "Parent" to the lifebar. In event 16 (group "enemy spawn") add an action "Lifebar: set Parent to enemy.UID" In event 28 (group "enemy reaches castle") add a condition "Lifebar: value Parent is equal to enemy.UID Only the current lifebar for the current enemy will be destroyed. You can also add a pin behavior to the lifebar and pin it to the enemy. => (You can notice I deleted the condition "Pick enemy IID" since it is not relevant as the correct instance is already picked by the condition "on collision".) |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Jul 2012 at 3:07pm |
|
|
Thanks to all that have helped! OK. So mouse events are fixed, although I switched to click instead of mouseover for interface reasons.
https://docs.google.com/open?id=0B5puA55FudSeTTA1ZVNvMmhwYlk The problem now is that once an enemy reaches the castle the health bars do not update correctly. When you run the game... LEFT CLICK on the circles on the map to build towers. RIGHT CLICK to destroy a tower. All works fine until one enemy reaches the end. I suppose the problem is in the destruction of the enemy and hp bar. Thoughts? |
|
![]() |
|
Post Options
Quote Reply
Posted: 03 Jul 2012 at 2:59pm |
|
|
I think you can get rid of the Pick IID event for the StoneTower; I believe the system has already got the correct ID based on the mouse cursor.
|
|
![]() |
|
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |