How to easily despawn an actor constrained to your touch position when you lift that touch

frankwashburnfrankwashburn Member Posts: 32
edited April 2012 in Working with GS (Mac)
Okay, so I want to track multi-touches on the screen as separate entities. My plan is to do this by constraining specific actors to each Touch input whenever a new Touch input is registered on the screen.

If you touch the screen with one finger, I want that to be "Touch 1". TouchTracker1 will spawn and constrain itself to that first touch.

If you place a second finger down on the screen, I want that to be "Touch 2." TouchTracker2 will spawn and constrain its coordinates to that second touch location.

If you remove your first finger from the screen, I want TouchTracker1 to destroy, but TouchTracker2 to still be alive and active.



I made some actors that I figured I'd just constrain the coordinates of:

Actor1 X,Y to Touch 1 -> X & Y
Actor2 X,Y to Touch 2 -> X & Y

etc etc.

However I'm running into some trouble.

I have an Actor that spawns these TouchTrackers using Devices>Touch>Count.

Rule:
When Attribute>Devices>Touch>Count = 1
Spawn: TouchTracker1 at the coordinates of Touch1 X/Y


And in TouchTracker1:

Rule:
Actor Receives event Touch released >Destroy Actor
Otherwise:
Constrain coordinates to Touch 1 X, Y.



However, this doesn't even work with the singular case. Pressing a single finger down spawns the actor and constrains it to your moving touch correctly... but lifting your finger doesn't destroy the actor.

This doesn't even account for the case of having TWO TouchTrackers. It'd work until you lifted Touch 1. Then because Devices>Touch>Count went from being 2 to 1, it'd respawn TouchTracker1. BLARGH.

!) Anyone have any suggestions for getting TouchTracker to properly destroy upon touch release? Why is that not triggering?
2) Is there a way to create a rule that tracks an Attribute TRANSITIONING from one value to another? Seems like a pretty basic game engine thing -> Rule: Trigger when Attribute x goes from x=2 to x=1, and at no other time.

Answers

  • frankwashburnfrankwashburn Member Posts: 32
    Also, if Devices>Touch1 does not exist, then what are the values of Touch1>X and Touch1>Y set to? Are they NULL values? Could be useful to actively check for that.
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    on the destroy, couldn't you have something simple like

    if actor receives touch inside
    ...
    OTHERWISE
    destory actor
  • frankwashburnfrankwashburn Member Posts: 32
    @jonmulcahy Just tried that, no dice. It seems that even though the actor is successfully being constrained to the touch1's coordinates, "touch inside" isn't even registering as True!! Neither is "Actor touch pressed", so "touch released" can't trigger because 'touch pressed' hasn't triggered yet.

    UGH
  • jonmulcahyjonmulcahy Member, Sous Chef Posts: 10,408
    you're right. I just tried making a quick demo, and I couldn't get it to work either. I have the touches working in the correct order, so touch 2 always spans a pink block, touch 3 always green ... but when I release the block they stay on the screen.

    the issue is, touch is pressed is not triggered unless you press down on the actual block, so when you spawn or move the actor to your touch point, it doesn't trigger the touch.

    I don't know if it's a bug or what
  • frankwashburnfrankwashburn Member Posts: 32
    Do you know how to report/log a bug to the Gamesalad team? I tried doing some google searches on how to do it and I haven't found anything. I have a prototype built that was working perfectly... except that a "touch is released" would randomly decide to not fire. Led me to have to rebuild the entire thing from the ground up, leading me to this problem... Touch is released isn't working. Ugh.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    edited April 2012
    At the bottom of every page of this site is report a bug. Its under support.
  • frankwashburnfrankwashburn Member Posts: 32
    @johnpapiomitis Thanks John.

    I revised the title of this discussion to make it more clear. I've gone through the forums looking for similar answers.. and there aren't many clear ones. It seems like if you want to do anything with multitouch, you have to prep yourself for a world of headache. Please prove me wrong!!
  • jckmcgrawjckmcgraw Member Posts: 647
    @frankwashburn

    Have you looked at the joystick template and its multitouch logic? It isn't perfect, but in general it works fine.
  • frankwashburnfrankwashburn Member Posts: 32
    @jckmcgraw I'm checking it out now, CodeMonkey's Nov 20th 2010 Joystick Template. It seems relatively robust - a few bugs, but it looks very promising. I can't FOR THE LIFE of me though find out WHERE he resets the sticks when you lift a touch - I see that he demands that game.StickxGrabbed be FALSE, but I've pored through every single actor and I can't find any rule that ever sets game.Stick1/2Grabbed = False. Any help or pointers appreciated.
  • frankwashburnfrankwashburn Member Posts: 32
    Crap, and where the heck are either of the stick's snapTo's attributes actually implemented? I see some checks for where SnapTo should be true or false, but I never see anything that says
    Rule: SnapTo is True, and snap the stick back to the center.

    Is there an actor-less layer of behaviors that I'm somehow missing here?
  • MotherHooseMotherHoose Member Posts: 2,456
    some … "Otherwise:" … ruleBehaviors in that template!

    EX: Stick2 actor 1st Rule: Hold the control on … check the Otherwise: section

    always good to add "√Otherwise:" to the name of rules that have those conditions

    image MH
  • frankwashburnfrankwashburn Member Posts: 32
    @motherhoose Oh jeez I'm dumb. I thought that the Otherwise tabs would have populated with their content automatically if they had anything - I thought they were all empty. I just had to click on the expand button. I'M DUMB
  • MotherHooseMotherHoose Member Posts: 2,456
    awe … Frank … if I wasn't dumb enough to most often miss the otherwise … I wouldn't have known where to look!

    GS should open the Otherwise when the rule is expanded … that would be the smart thing to do!

    image MH
Sign In or Register to comment.