Arggg Dilemma -- How To Cancel Touch Message ???

netdzynrnetdzynr Member Posts: 296
edited November -1 in Working with GS (Mac)
I have a situation where one touchable actor overlaps another -- I want the top most actor to cancel out any touch messages from reaching the bottom actor while the top most actor is doing stuff.

The top most actor sets a game attribute when it is touched that says it's "busy". On release, the top most actor waits 1 second before setting the busy attribute to false. So far so good.

The bottom object has a rule that says "on release, only do stuff if the busy attribute is false". The problem is, the bottom actor will wait out the 1 second until "busy" is false and then react to the release message.

I don't want this to happen. I assume both actors get the touch release message at the same time, but the bottom actor somehow hangs on to the release "state" until after the 1 second delay has passed! Is there some way to cancel out the release message for the bottom actor?

Arggg.

Thanks for any suggestions.

Comments

  • firemaplegamesfiremaplegames Member Posts: 3,211
    Is this in a controlled environment?
    Like in a menu system, or if there are only a specific number of Actors at a time?
  • netdzynrnetdzynr Member Posts: 296
    Yes, I would say that. All the menu options are based on the same set of rules. There would be a fixed number of actors on screen in this scene. Does that mean a solution is possible?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I use a 'busy' flag as well in my games...

    Regardless of the busy flag, does each button do a different task?

    i.e:

    Press button 1 - something happens?
    Press button 2 - something else happens?

    And are these buttons always overlapping in the same position? Or do they move? Either by themselves, or by dragging?

    Also, does one button always trump the other one? i.e., button 1 should take precedence over button 2 if they are both clicked?

    Sorry, I am just trying to get a clearer picture.

    Overlapping things are a big pain in GameSalad, especially since you do not have access to the Z position of an Actor.

    But if it is in a closed, controllable system - you can lock it down with different boolean flags and stuff.
  • netdzynrnetdzynr Member Posts: 296
    Thanks for answering -- I'll try to answer your questions...

    If I understand what you're asking, the scene set up is "closed" -- it is a menu screen screen of sorts that takes the player to any of 12 scenes in the game. There are 12 "launch" buttons in the scene. This does not change. I am opening the "menu" actor above the launch buttons, and if a menu option happens to fall on top of one of the launch buttons, the launch button gets triggered as soon as the menu's "busy" flag is set to false, even if the flag change is delayed. I don't see how to get around this -- I tried setting multiple flags, increasing the delay, and STILL the darn launch button gets a touch-is-released message.

    How can this possibly be considered desired behavior? It seems to me the touch event should be ignored if it's not handled immediately by an actor.

    Anyway, I've thrown everything I can think of at this, so if you have some other insight, I'd love to hear it.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    A menu? Pssh. Easy Peasy.

    I do this as well as I have some popups on my menu, i.e, "Are you sure you want to do that?" "Yes". "Cancel". etc...

    So, you can easily accomplish this with just your one boolean, 'busy'.

    On the regular buttons, the ones that don't pop up menus, just add the busy condition to their Rules, like this:

    Rule
    When all conditions are valid:
    Touch is Pressed
    game.busy is false
    -----[do whatever]

    On the buttons that pop up menus, do this:

    Rule
    When all conditions are valid:
    Touch is Pressed
    game.busy is false
    -----Change Attribute: game.busy To: true
    -----Change Attribute: game.showPopup To: true

    I'm assuming that the popup menus are there all the time and you're just toggling their alpha between 0 and 1.

    In the popup menu, do this:

    Rule
    When all conditions are valid:
    game.showPopup = true
    -----Change Attribute: self.alpha To: 1
    otherwise
    -----Change Attribute: self.alpha To: 0

    Rule
    When all conditions are valid:
    Touch is pressed
    -----[do whatever]
    -----Change Attribute: game.showPopup To: false
    -----Change Attribute: game.busy To: false

    That SHOULD work fine. If for some reason it isn't, let me know.

    Also, I would try to use Touch is Pressed if you can instead of Touch is Released as it makes your game seem more responsive. It's subtle, but it helps.
  • netdzynrnetdzynr Member Posts: 296
    Hey Joe...

    Thanks for the above suggestion, but it's similar to what I tried, and I don't believe it works. I set up the simplest of projects (can send it to you if you wish) with 2 actors that overlap. The top (overlay) actor sets a busy flag, and the bottom (underlying) actor has display text that is only supposed to trigger when the busy flag is false. Even with just these 2 actors in the scene, the display text in the bottom actor pops up momentarily, which says to me that either the actors are getting the touch pressed message at the same time, or the bottom actor is getting the message first. In either case, the behavior seems incorrect to me, as the top actor is the front most object and I would imagine *should* be the first object to get the message. Maybe GS sends messages from the bottom of the pile upward, I don't know.

    That being said, I believe I found a solution -- there's an "actor receives event" option of "overlaps or collides" with another actor of a specified name or type. This seems to effectively tell the bottom actor to chill while the top actor does its thing. The only limitation is it's positive interaction only -- you can't negate it ("if actor receives event DOESN'T overlap or collide..."). It'll be a pain to rewrite all the interaction in the game to take advantage of this, but it seems like it will work.

    Thanks again as always for your offer to help. And I hope this saves other folks some bloody foreheads.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    netdzynr said:
    The only limitation is it's positive interaction only -- you can't negate it ("if actor receives event DOESN'T overlap or collide...")

    You can put stuff in the 'otherwise' section to act as the negation.

    I'll post a simple demo that shows popup menus...

    And yes, I do wish actors had a flag that said "click-throughable" or something.

    As it stands, it is currently impossible to make a solitaire game for example, as you would click on all the cards at once.
  • victorkin11victorkin11 Member Posts: 251
    I don't think "overlaps or collide" will told you which one is the top!
  • netdzynrnetdzynr Member Posts: 296
    Right, I know about the "otherwise" pane and use it often, but it's somewhat evil in that (at least on my end) it's often closed (or gets closed) in Creator until I explicitly expand it, so a lot of behaviors can mistakenly go unseen.

    Love the new attribute name: "Click-throughable" lol.
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I made you a quick demo here:

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

    Hopefully this helps!
  • paulthomsonpaulthomson Member Posts: 1
    I have two actors one to go to instructions and one to go to the play area. I've setup the rule on both actors to change screen...one to the instructions and the other to the game screen. I've put both actors right over the instructions and play graphics. But, when I run it. I could click anywhere and the instruction screen comes up. Even when I click the play the instruction loads. Is there a way to have multiple actors on the same screen that does different thing. Like once actor to load the Instructions and the other actor on the same screen to load the game. Please help. I couldn't get that done. Thank you in advance!!!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You need to change the condition of your Rule from Mouse is Down to: Touch is Pressed.

    Mouse is Down works on the entire screen whereas Touch is pressed only works on the Actor itself.
Sign In or Register to comment.