I'm working on a touchscreen game for multiple players. The idea is that a player can tap the screen anywhere once to create a canon, then drag the canon around to control it. If another player wants to join, they can tap anywhere as well to create another canon (as long as they're not within a certain radius of any other canons to avoid accidental spawns by one person).
I've got the basics of this implemented, however, I've noticed that I can't seem to be able to spawn any new canons while any existing canons are being touched. So, if one player is dragging a canon around, the other player's touch will do nothing until the first player lets go of their canon. Also, if two players touch the screen at nearly the same time, only one will spawn a canon. It's worth noting that, once spawned, all canons can be moved at the same time, so it's definitely picking up all the touches (just not when spawning objects is involved.)
Can someone explain what I could possibly be doing wrong here? I've done all sorts of tinkering with the code and nothing seems to remedy this problem. My capx is attached.
Develop games in your browser. Powerful, performant & highly capable.
Update: Okay, figured out the problem, but the solution still escapes me.
I don't want canons to spawn too close to each other, so I create a "noSpawnZone" around them at the same time the initial touch creates a new canon. However, by adding the condition "Touch is NOT touching a noSpawnZone" to the "On any touch start event", it restricts any new canons from being made while an existing canon is being touched (because there's a "noSpawnZone" being touched SOMEWHERE).
So, is there a way to "pick" the touch being referenced on the "Any touch start", so it would only check if the touch that triggered the event is touching a "noSpawnZone" rather than checking if ANY touch is?