How to differentiate between touching actor or background

thegwillthegwill Member Posts: 31
edited November -1 in Working with GS (Mac)
Here's my problem:

I have a simple actors moving around over a background.
I have a rule on the actor to change color when touched.
I have a rule on the background to change color when touched.

If I touch the background it works as expected.
If I touch the actor then the actor changes color AND the background changes color.

Any suggestions? - I'm sure it's something simple!

Comments

  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    For the movable actor use mouse button down or up instead of press. Or if using press, also use is inside.
  • thegwillthegwill Member Posts: 31
    Thanks for replying...

    But that didn't work. I tried using the mouse events instead of "touch" and the rule for the background actor is still firing.

    Maybe if I explain a bit better:

    The background actor occupies the whole screen.
    The moving actor is about 25x25 and moves around on top of the background. There can be lots of these.

    When I touch the screen, either:
    1. I missed the moving actor and touched the background. This works fine.
    2. I touched the moving actor. I do get this event BUT I also get a background touched event too. I've tried the mouse events and the touch events - both same problem.

    Any ideas?
  • TouchTiltGamesTouchTiltGames Member Posts: 1,162
    Use a change attribute, simply an integer that when actor is pressed, background is 0
  • thegwillthegwill Member Posts: 31
    In the last 10 mins I did try a "hack" with the boolean flag set by the actor and then checked in the background rule but that also didn't work.

    Does anyone out there have a simple demo for how to do this? It sounds so simple... ;o)
  • JackBQuickJackBQuick Member Posts: 524
    The is the only thing that I've tried which works:

    Identifying actor and background (demo)

    I have three actors: player, background, and detector.

    When player is pressed, it changes colour.

    When background is pressed, it spawns detector.

    If detector overlaps or collides with player, it destroys itself. If, after 0.05 seconds, it still exists it changes a global attribute called changeBackground to 0 (if it was 1) or 1 (if it was 0), and then it self-destructs.

    I've constrained self.Color.Red of the background actor to the value of changeBackground.

    I don't know how well this will work with moving actors but you can try for yourself to see.

    Cheers!
  • thegwillthegwill Member Posts: 31
    Sounds helpful, thanks - I'll give it a try.
Sign In or Register to comment.