Tower Defense

0 favourites
  • 13 posts
From the Asset Store
Tower stacker
$9.99 USD
Template for a tower stacker game, fully documented in comments and video
  • I have asked several questions here in the last couple of days and of course here is another one!

    I have followed several pieces of advice here on the forum and this is what I have made.

    docs.google.com/open

    If you run the layout you will notice that at some point the towers will shoot the enemy that is farthest to the right but will NOT shoot the ones on the left.

    So the TOWERS on the FAR right shoot but middle and left towers do not.

    Any thoughts?

  • I think you have a typo in Event 5.

    You used this condition:

    StoneTower: pick closest to (StoneTower.X, StoneTower.Y)

    You should use this instead:

    Enemy: pick closest to (StoneTower.X, StoneTower.Y)

  • Thanks ROJO! You were right! It works perfect now!

    Last thing if you might look. I have a mouseover event for the towers to display information. It will eventually show a context menu for upgrading etc.

    It only seems to work on the middle tower for some reason!

    Any thoughts? It is in the MouseControls Group.

  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks to all that have helped! OK. So mouse events are fixed, although I switched to click instead of mouseover for interface reasons.

    docs.google.com/open

    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?

  • 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.

    =>

    <img src="https://dl.dropbox.com/u/36472942/construct/forumhelp/EnemySpawn_TD.PNG" border="0" />

    <img src="https://dl.dropbox.com/u/36472942/construct/forumhelp/EnemyReachesCastle_TD.PNG" border="0" />

    (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".)

  • Awesome! Thank you! I am getting better at Construct Events but still have some work to go! I appreciate the communities help!

  • 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?

    docs.google.com/open

  • 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.

  • 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.

  • docs.google.com/open

    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!

    <img src="smileys/smiley1.gif" border="0" align="middle" />

  • 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.

    docs.google.com/open

    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

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)