Correct me if I'm wrong but I don't think either of these are going to work (at least not in all situations)
One problem is that you never know which finger the player will touch the screen with first. So for example you cannot assume that touch2.X will be greater than touch1.X (and the same is true for touch.Y)
Here's what I would do:
Rule if touch.count >= to 2 -----Rule if touch2.X > touch1.x ---------change attribute game.middleX to (touch1.X + ((touch2.x-touch1.x)/2)) -----OtherWise ---------change attribute game.middleX to (touch2.X + ((touch1.x-touch2.x)/2)) -----Rule if touch2.Y > touch1.Y ---------change attribute game.middleY to (touch1.Y + ((touch2.Y-touch1.Y)/2)) -----OtherWise ---------change attribute game.middleY to (touch2.Y + ((touch1.Y-touch2.Y)/2))
@scitunes, magnitude uses the absolute value so there won't be a negative distance. It shouldn't matter what the coordinates are, or which is bigger. -C
He said he wants the middle coordinates. For this you need to know if you are adding half the distance to touch 1 or if you are adding half the distance to touch 2. To do that you need to know which one is greater.
Answers
Solution:
PositionX = (Touch1.X + Touch2.X)/2
PositionY = (Touch1.Y + Touch2.Y)/2
Magnitude(touch1x-touch2x, touch1y-touch2y) /2
-C
One problem is that you never know which finger the player will touch the screen with first. So for example you cannot assume that touch2.X will be greater than touch1.X (and the same is true for touch.Y)
Here's what I would do:
Rule if touch.count >= to 2
-----Rule if touch2.X > touch1.x
---------change attribute game.middleX to (touch1.X + ((touch2.x-touch1.x)/2))
-----OtherWise
---------change attribute game.middleX to (touch2.X + ((touch1.x-touch2.x)/2))
-----Rule if touch2.Y > touch1.Y
---------change attribute game.middleY to (touch1.Y + ((touch2.Y-touch1.Y)/2))
-----OtherWise
---------change attribute game.middleY to (touch2.Y + ((touch1.Y-touch2.Y)/2))
-C
PositionX = (Touch1.X + Touch2.X)/2
PositionY = (Touch1.Y + Touch2.Y)/2
Works perfectly (any direction, + or -, doesn't matter). No need to add rules or per-fabricated functions in the expression editor.
(magnitude(point1.y - point2.y , point1.x - point2.x))/2