Cannot get this to work! *Help*
chosenonestudios
Member Posts: 1,714
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!
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
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.
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
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]
is that what I should do?
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?
How would I give the touches values?
would I constrain the self.position to all the touches?
What value do you want to give to the Touches?
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
Hmmm... Should I upload my project?
I didn't think you can test multitouch just through gamesalad...
I'm not sure though.
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
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
Same method only without the > 240 conditions?
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.