How do I spawn an object on different object?

Get help using Construct 2

Post » Wed Nov 30, 2016 4:05 am

Hey! I'm making a game (tower defense) and when when I drag a tower over an area and drop it there, it's suppose to spawn a new object on the area(which is a sprite), but the problem is that if it's over two of the same areas, I don't know which one it's gonna land on. Can someone help me?
B
13
S
1
Posts: 16
Reputation: 563

Post » Wed Nov 30, 2016 9:19 am

CavalierBubble wrote:Hey! I'm making a game (tower defense) and when when I drag a tower over an area and drop it there, it's suppose to spawn a new object on the area(which is a sprite), but the problem is that if it's over two of the same areas, I don't know which one it's gonna land on. Can someone help me?


The best and easiest way to solve this is to use a pick nearest/furthest action, when you drop the tower on the sprite where you want to spawn it. I guess you have some conditions that when you drop the Tower you want to place, you also check whether its overlapping this sprite where you can place it.

Now if the Tower overlaps several sprites your pick counter of those sprites is likely to be greater than 1, but since you are also for certain closer to the sprite where you actually want to place the tower than those where you don't want to. You can use the pick nearest/furthest action to pick the sprite closest to the Mouse.X, Mouse.Y.
B
44
S
11
G
2
Posts: 1,182
Reputation: 6,828


Return to How do I....?

Who is online

Users browsing this forum: davidbox, Mayfly, Yahoo [Bot] and 4 guests