August 22, 2010

codes for touch in iphone

Every user should control game easily. Game controlling can be doing with  keypress
or touch or device(in iphone and some device).Which one you like?In iphone or even
java you should use events for every user command .In  this article we  focused on
touch events and codes.

a touch can be occurred in interface that i discussed in previous article. For any touch
and interface you should define function and connection from interface to function.
if you want use button button have many touch event like touch cancel,touch
down,touch up inside and etc.With right click in button in mainwindow you’ll see
events, select one of them and connected it to window select function you create for this image

For other part of windows you shoul add more code .A code like it can be use
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
with this code you can define point for your touch .
CGPoint  lastPoint;
and in part of program that you can use it for detect your finger.
CGPoint gamePoint = [touch locationInView:self.view];
you can get coordinates of point.
in next post we discussed detailed about game making and also i’ll add more source code.
Read more »