Cannot get this to work! *Help*

chosenonestudioschosenonestudios Member Posts: 1,714
edited November -1 in Working with GS (Mac)
I've been working on this all day and cant get it to work... so frustrated.....

So basically I have two actors and I need to move them both at the same time...

I had some limited success with using touch 1 and touch 2, but the problem is when you click on one first thats touch 1 and I don't know how to tell it to handle all of the equations...

If you have any suggestions it would be greatly appreciated. :)

Thanks!

P.S. Please do not, do not tell me to use CodeMonkeys analog control demo because I can't make heads or tails of it!

Comments

  • PhoticsPhotics Member Posts: 4,172
    I hate the controller demo too. Usually, as a workaround, I restrict touches to areas of the screen. However, that might not work if the two actors will overlap or go to the same parts of the screen.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    No they won't, but how do you restrict to areas of the screen? thats what I cant figure out :/
  • PhoticsPhotics Member Posts: 4,172
    I usually do it based on mouse position...

    Rule... if touched is pressed...

    If mouse position Y is > 240... blah blah blah
    Else... blah blah blah

    I'm not sure if that's going to work with multiple touches though.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    ok, but.....

    i can't use mouse.position because I have two different actors that need this information....

    So i have to use mouse.touch1 and touch2, but these flip flop when you touch the actors in different orders.... so you have to use something in screen area, but I don't know how unfortunately :/
  • firemaplegamesfiremaplegames Member Posts: 3,211
    You need something like this:

    Rule
    When ALL conditions are valid:
    Touch is Pressed:
    -----Rule
    -----When ANY conditions are valid:
    -----game.Touch1.X > 240
    -----game.Touch2.X > 240
    -----game.Touch3.X > 240
    -----game.Touch4.X > 240
    -----game.Touch5.X > 240
    ----------[do something]
  • chosenonestudioschosenonestudios Member Posts: 1,714
    ty fmg, question though... for what to make it do, constrain game.self.postition.x to game.touch.1 position.x

    is that what I should do?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    In that case, maybe something like this?

    Rule
    When ALL conditions are valid:
    Touch is Pressed:
    -----Rule
    -----When ALL conditions are valid:
    -----game.Touch1.X > 240
    ----------Constrain Attribute: self.Position.X To Touch1.X
    ----------Constrain Attribute: self.Position.Y To Touch1.Y
    -----Rule
    -----When ALL conditions are valid:
    -----game.Touch2.X > 240
    ----------Constrain Attribute: self.Position.X To Touch2.X
    ----------Constrain Attribute: self.Position.Y To Touch2.Y
    -----Rule
    -----When ALL conditions are valid:
    -----game.Touch3.X > 240
    ----------Constrain Attribute: self.Position.X To Touch3.X
    ----------Constrain Attribute: self.Position.Y To Touch3.Y
    -----Rule
    -----When ALL conditions are valid:
    -----game.Touch4.X > 240
    ----------Constrain Attribute: self.Position.X To Touch4.X
    ----------Constrain Attribute: self.Position.Y To Touch4.Y
    -----Rule
    -----When ALL conditions are valid:
    -----game.Touch5.X > 240
    ----------Constrain Attribute: self.Position.X To Touch5.X
    ----------Constrain Attribute: self.Position.Y To Touch5.Y

    That should be for the right actor. The left actor would need "< 240" to work.
    I haven't tried it, that's just off the top of my head, but maybe something like that?
  • chosenonestudioschosenonestudios Member Posts: 1,714
    ty fmg, will try right now! I'm pretty excited about this! Thank you! Will see how it goes!
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Ok hopefully last stupid question...

    How would I give the touches values?

    would I constrain the self.position to all the touches?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    I'm not sure I understand?
    What value do you want to give to the Touches?
  • chosenonestudioschosenonestudios Member Posts: 1,714
    alright it didn't work I'm not sure why, but actor 1 (uses touch. y < 240) and when its clicked it goes flying off into the bottom left hand corner and then can't be moved

    actor 2 (uses touch.y > 240) it goes about its business as usual except its a little laggy

    (Maybe from all the constrains)

    P.S. I copied and pasted the code from actor 1 to 2 so I think the codes all right, but I can't figure out whats going on.

    -Sigh-

    I won't give up though, I WILL make this work!

    Haha funny cause will is my name
  • chosenonestudioschosenonestudios Member Posts: 1,714
    firemaplegames said:
    I'm not sure I understand?
    What value do you want to give to the Touches?

    I thought you had to give the value to the touches to make them work... But if you don't just another stupid question haha

    Hmmm... Should I upload my project?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Also, are you testing this on a device?

    I didn't think you can test multitouch just through gamesalad...

    I'm not sure though.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    Yes on my ipod touch (2nd gen)
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Only two of those constrains should be firing at any given time for each actor...

    But if you have two actors that you are controlling, you will then have a total of 4 running all the time.

    Also, and I should have done this in the above post, but you should put each consecutive Touch Rule in the otherwise section. That way once it reaches the correct one, it won't check the remaining ones.

    So:

    Rule
    When ALL conditions are valid:
    Touch is Pressed:
    -----Rule
    -----When ALL conditions are valid:
    -----game.Touch1.X > 240
    ----------Constrain Attribute: self.Position.X To Touch1.X
    ----------Constrain Attribute: self.Position.Y To Touch1.Y
    ----------otherwise
    ---------------Rule
    ---------------When ALL conditions are valid:
    ---------------game.Touch2.X > 240
    --------------------Constrain Attribute: self.Position.X To Touch2.X
    --------------------Constrain Attribute: self.Position.Y To Touch2.Y
    ---------------otherwise
    --------------------Rule
    --------------------When ALL conditions are valid:
    --------------------game.Touch3.X > 240
    -------------------------Constrain Attribute: self.Position.X To Touch3.X
    -------------------------Constrain Attribute: self.Position.Y To Touch3.Y
    --------------------otherwise
    -------------------------Rule
    -------------------------When ALL conditions are valid:
    -------------------------game.Touch4.X > 240
    ------------------------------Constrain Attribute: self.Position.X To Touch4.X
    ------------------------------Constrain Attribute: self.Position.Y To Touch4.Y
    -------------------------otherwise
    ------------------------------Rule
    ------------------------------When ALL conditions are valid:
    ------------------------------game.Touch5.X > 240
    -----------------------------------Constrain Attribute: self.Position.X To Touch5.X
    -----------------------------------Constrain Attribute: self.Position.Y To Touch5.Y

    At any rate, 4 constrains running all the time is pretty taxing on older hardware like the iPhone 3G
  • chosenonestudioschosenonestudios Member Posts: 1,714
    alright ty fmg, I'll go try that out!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    That's all I got though. Hopefully someone who has made a multitouch app can help you out.
  • chosenonestudioschosenonestudios Member Posts: 1,714
    firemaplegames said:
    That's all I got though. Hopefully someone who has made a multitouch app can help you out.

    That's all I needed! Hoorah! I will stop spamming the forums with help now haha

    Tyvm Joe!

    You are definitely going in my credits!

    I really appreciate your help, sorry for being such a pest :/

    Well good night, I'm tired as hell
  • iPhoneDevForMeiPhoneDevForMe Member Posts: 362
    How would this be used for touching anywhere on the screen to move multiple instances of the same actor at the same time?

    Same method only without the > 240 conditions?
  • chosenonestudioschosenonestudios Member Posts: 1,714
    iPhoneDevForMe said:
    How would this be used for touching anywhere on the screen to move multiple instances of the same actor at the same time?

    Same method only without the > 240 conditions?

    Yea, I think so
  • rebumprebump Member Posts: 1,058
    @iPhoneDevForMe: I would think when you are not restricting on X/Y location, your work is a bit more involved. You may have to add game level attributes that keep track of a true/false (or 1/0) status of a touch being currently constrained...otherwise all the actors would constrain to the first touch.

    So add some game attributes:

    `
    Touch1Constrained - boolean (or integer)
    Touch2Constrainted - boolean (or integer)
    ...
    `
    Then in your logic, add a conditional:

    `
    ...and if TouchXConstrained is false (or 0)
    then
    set TouchXConstrained to true (or 1)
    and constrain this actor's X/Y to TouchX's coordinates
    `
    Then upon that touch releasing, set `TouchXConstrained` back to `false (or 0)`.

    Not sure if timing issues would erupt though with many actors fighting over a touch. Testing would reveal if there was any issue. Guessing it should work.
Sign In or Register to comment.