ios - midway x and y coordinates of an iPhone -
I am trying to figure out where a tap is located on the App view. Some people have said I say 160 for X, but they do not know about Y.
For now I just need X, but y is not aware of knowing. I have to do this to differentiate between left and right edge of the scene. You should not hardcode the dimensions of the tools in your code, some more android developers have a lot of conflict have to do. Width is the same for iPhone 4 and iPhone 5, but the height is different Also, what happens when the orientation changes? You should request dimensions by code instead, code here to get two middle digits: - (Zero) touches: (NSSET *) touches the event: (UIEVENT *) event {UITT * METCH = [touches an object]; CGPoint aPoint = [myTouch locationInView: self.view]; // Touch the X Codes of Touch if (aPoint.x> <160) {// Left Player Player.image = [UIImage imageNamed: @ "Person1.png"]; [NSTimer scheduled timer with time interval: 0.25 target: self selector: @sillector (change image left) userInfo: zero repeats: no]; } If (aPoint.x> = 160) {// right side Player2.image = [UIImage imageNamed: @ "Person1.png"] touches; [Nstimer scheduled timer with time interval: 0.25 target: self selector: @sillector (change imageRight) userInfo: zero repeats: no]; }}
- (zero) done by the thorontform interface (UIInterfaceOrientation) Interface Orientation {CGFloat midX = CGRT's GateWidth (Auto View.bond) / 2.0F; CGFloat midy = CGRectGetHeight (self.view.bounds) / 2.0f; }
Comments
Post a Comment