Dragging multiple actors over one another

spaceneedlespaceneedle PRO Posts: 93
edited November -1 in Working with GS (Mac)
I am working on an application that allows you to drag multiple actors around the screen, including on top of one another.

This dragging example is great:

http://gamesalad.com/game/play/30842

HOWEVER -- When two actors are on top of one another, they both receive the touch inside event, rather than the top one masking the bottom. Is there any way for an actor to detect if its on top or only receive the touch inside event if its not covered by another?

The current behavior ends up causing anything that qualifies inside, no matter what its "Z" position is to "cling" like a magnet to the finger press. Any pointers?

On a slightly different question, is there any way to modify attributes of an actor's Z position in the rules, besides going into the scene and right clicking the actors themselves?

Comments

  • synthesissynthesis Member Posts: 1,693
    You need to use an active actor ID switch.
    On touch.press
    when game.ActiveActorID = 0
    game.ActiveActorID = self.UniqueActorID

    when game.ActiveActorID = self.UniqueActorID >>> drag is enabled.

    on touch.release
    game.ActiveActorID = 0

    Using the game ID switch to make only 1 actor respond to the drag

    here is a link to a tip on how to use actor IDs
    http://www.gsproforum.com/viewtopic.php?f=17&t=44

    Hope this helps out.

    RE: Z orders...to my knowledge...there is no in-game z ordering functionality. however...you can spawn to certain layers...and the layers act as a z-ordering system...upper scene layers are above lower layers.
  • spaceneedlespaceneedle PRO Posts: 93
    Thank you! This definitely fixes the horrid touch-o-magnet effect. Only one active, even if overlapping, actor is picked up by the touch-and-drag rule.

    Is there any solution you can think of to have the "touch inside" select the top actor if it masks the actor below it?

    Imagine, if you will a tree with large apples, both of which are draggable actors. When I go to pick up one of the apples, it goes behind it and drags the tree. While it makes sense from a scripting standpoint, it is counterintuitive to the user why a tree is being dragged when they clearly selected the apple. I am clearly hitting a limitation in GameSalad, but I wanted to get some consensus on this before I go to plan B and/or make a suggestion regarding it.
  • jkornoffjkornoff Member Posts: 55
    Wow. I'm really glad I came across this post. This is a problem I had with my "Detonate" game. The solution here should fix my problem perfectly. Time for an upgrade to the app now anyway! Thanks!
Sign In or Register to comment.