mercredi 25 février 2015

About touch coordinate between iPhone 4s, 5, 6 and 6+

Fyi, I am new to Xcode programming for IOS. I've written a simple game and tested on actual iPhone 4s and is working. As I only own iPhone 4s, I can only simulate my game with iOS simulator for higher iPhone version. The problem I observed for higher iPhone version is that the image is scaled, therefore the touch location is no longer valid.


PS: I do not use any UIButton. I am using CGRectMake to create the button and later declare the touch position as shown below.



-(void) touchBegan: (CGPoint) p {
if (p.x > 0 && p.x < 100 && p.y > 0 && p.y < 30) myscore = 1;


}


So my question is, will the touch displacement seen in the simulator appear the same in the actual device? If yes, does it means that I need to declare the touch boundary for each iPhone version?


Thanks in advance for any advice.




Aucun commentaire:

Enregistrer un commentaire