How to Touch-to-Drag when actors overlap? Tricky!
jkornoff
Member Posts: 55
Sorry for the long post, but this problem may help others out.
I'm going back in to Detonate! and making small fixes and tweaks. One thing I wanted to fix with 1.0 is what I perceived as a bug when if you spawned multiple bombs at one time (and they spawn on top of each other) and you try to drag one off the 'top of the pile', there would only be that one visible. The other wouldn't be seen below it. They disappeared.
So I thought I would be smart and slightly randomize the spawning location of the bombs so that they don't appear right on top of each other. Problem solved! Nope.
Clicking or touching one makes the others disappear too. Then I realized that maybe they WEREN'T really gone at all, but instead they were all being moved together, one on top of each other as a group! My touch-to-drag behavior is selecting all the actors under the touch, lining them all of them up on top of each other (because constrain self.position to game.mouse position).
This is what is happening, I've confirmed it. I have no idea how to fix it!
I could create some sort of rule that doesn't allow actors to overlap. That's pretty hard!
I wish there was a way to limit the click to drag to only the actor on 'top' so that if you had a stack, you could just drag that one off and reveal the others below it instead of selecting all the actors in the stack. It's like the 'touch' is penetrating through all the layers in the scene.
One thing I wanted to do in v1.1 was to increase the touch area of the bombs so that they were easier to move with your finger on the iPhone. Well, obviously this would mean there is more of an area for multiple bombs to overlap then and this problem gets worse.
Any ideas?
You can see what I'm talking about by going into Detonate! lite and creating three red bombs in a row on Level 2. http://gamesalad.com/game/play/36739
I'm going back in to Detonate! and making small fixes and tweaks. One thing I wanted to fix with 1.0 is what I perceived as a bug when if you spawned multiple bombs at one time (and they spawn on top of each other) and you try to drag one off the 'top of the pile', there would only be that one visible. The other wouldn't be seen below it. They disappeared.
So I thought I would be smart and slightly randomize the spawning location of the bombs so that they don't appear right on top of each other. Problem solved! Nope.
Clicking or touching one makes the others disappear too. Then I realized that maybe they WEREN'T really gone at all, but instead they were all being moved together, one on top of each other as a group! My touch-to-drag behavior is selecting all the actors under the touch, lining them all of them up on top of each other (because constrain self.position to game.mouse position).
This is what is happening, I've confirmed it. I have no idea how to fix it!
I could create some sort of rule that doesn't allow actors to overlap. That's pretty hard!
I wish there was a way to limit the click to drag to only the actor on 'top' so that if you had a stack, you could just drag that one off and reveal the others below it instead of selecting all the actors in the stack. It's like the 'touch' is penetrating through all the layers in the scene.
One thing I wanted to do in v1.1 was to increase the touch area of the bombs so that they were easier to move with your finger on the iPhone. Well, obviously this would mean there is more of an area for multiple bombs to overlap then and this problem gets worse.
Any ideas?
You can see what I'm talking about by going into Detonate! lite and creating three red bombs in a row on Level 2. http://gamesalad.com/game/play/36739
Comments
It would be nice to have a way to trap all touches in the highest actor in the layer(s)...
I have tried as many things as I can think of, but I don't see a way around this issue currently.
It wasn't perfect and you couldn't guarantee which actor would receive the event. It was a hack and it was on 0.7.0 that I got it sort of working... I haven't tried it in 0.8.2
Create a real attribute in the actor called something like 'touchOffset'
Create a Rule like this in the Actor:
Rule
When Touch is Presses
Change attribute self.touchOffset to: game.Devices.touch1.X - self.Position.X
Constrain Attribute self.Position to: Touch1.X+self.touchOffset
That should do the trick. Not sure about multitouch, but this should get you going in the right direction
@orbz - "The timer makes parallel operations linear and each new actor is just a little bit slower than it's previous."
Can you expand on that a little bit? The next problem I face is that simultaneous actions (detonations) controlled by timers work great on GS web, but don't work well at all on the iPhone. If I trigger two of the same-type bombs at the same time on the iPhone, nothing happens. The two cancel each other out it seems. Two different types at the same time or two of the same type but set different timers work fine on the Phone.
Any and all combos work fine on the web, so its hard test. Your comment may provide some insight.