How to select just 1 actor when many at your finger touch

carlos.varela.comcarlos.varela.com Member Posts: 99
edited November -1 in Working with GS (Mac)
Hi guys,

My project is stoped since weeks for this matter, and I really will appreciate your help on this.

I have many actor in my game that collide between them, but without bouncing, not phisics, not moving from one side to another, I need to select just one actor in order to change the action or status, but the problem is that when I did touch, sometimes I touch more than one and the actor go crazy, one of them follow why I did spect to do, but the other just stop, or do another things, etc.

I have been creating a unique id for each actor, an actor attribute id, when spawn, and have a global attribute that I change to true or false depends the status or action that I need to apply and each actor check if it was touched and compare his unique id with the global attributes in order to do something or not, in the case that I was not touched or I am not the unique Id actor that was touched then I don't do anything or do another thing.

When I did touch an actor the other actor do another thing well, the problem is when some actors are the same moment when I did touch, the other goes well, but these collided, one do my action or status, but the other don't know what to do I think.

Comments

  • carlos.varela.comcarlos.varela.com Member Posts: 99
    ...
  • 2D-Sprite-Box2D-Sprite-Box Member Posts: 72
    I'm not sure what you are asking
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    There are other threads on this topic. I don't know the answer to your issue, but if I remember correctly FMG and other experienced GSers have said that without access to an actor's Z index it would be very difficult to determine which actor is on top.
  • carlos.varela.comcarlos.varela.com Member Posts: 99
    First, thanks for your help!
    Z index:
    I did spawn all my actors when The scene begin, I think that each actor is positioned at different z índex adress, but not sure, because when I touch just one follow what I spect to do, I think that maybe it's the top actor, but not sure.
    Every himself check his own unique id and if he was touched too, when touched I did set a global attribute of the actor that have right now the status of "touched", this the way I use to check if himself is the touched actor, then do some rules in order to change the actor direction or status, etc.
    The problem is the other touched actors, I think behind this actor on top, that do the same check, and maybe trying to set the global attribute at the same time at this actor on top.
    But the strange and curious is that just only one do the spected, but the other stop or do something not spected or crazy.
  • scitunesscitunes Member, Sous Chef Posts: 4,047
    currently there is no Z index support. Maybe someday????
  • 2D-Sprite-Box2D-Sprite-Box Member Posts: 72
    Try setting each actor with a different length timer for touch time, something with a small difference
  • carlos.varela.comcarlos.varela.com Member Posts: 99
    Sound good, but how can I do that?
  • carlos.varela.comcarlos.varela.com Member Posts: 99
    How to z-index?
    Any idea?
Sign In or Register to comment.