Tower Defense

Get help using Construct 2

Post » Tue Jul 03, 2012 4:59 am

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.

https://docs.google.com/open?id=0B5puA55FudSeLUJqVjlGQUItc2M

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?
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Tue Jul 03, 2012 6:08 am

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)
B
79
S
24
G
54
Posts: 4,747
Reputation: 40,757

Post » Tue Jul 03, 2012 12:59 pm

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.
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Tue Jul 03, 2012 2:59 pm

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.
B
9
S
2
G
3
Posts: 75
Reputation: 1,964

Post » Tue Jul 03, 2012 3:07 pm

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?
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Tue Jul 03, 2012 3:33 pm

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".)
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Tue Jul 03, 2012 3:57 pm

Awesome! Thank you! I am getting better at Construct Events but still have some work to go! I appreciate the communities help!
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Tue Jul 03, 2012 9:01 pm

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
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

Post » Tue Jul 03, 2012 9:43 pm

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.
sparkdad2012-07-03 23:01:02
B
12
S
1
G
1
Posts: 50
Reputation: 1,228

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 !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Next

Return to How do I....?

Who is online

Users browsing this forum: jeffige and 22 guests