Making things Move on the iPhone
-
Upload
john-wilker -
Category
Technology
-
view
3.706 -
download
2
description
Transcript of Making things Move on the iPhone
![Page 1: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/1.jpg)
Making Things Moveon the iPhone
Keith Peterswww.bit-101.com
Wednesday, March 4, 2009
![Page 2: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/2.jpg)
www.bit-101.com/360iDev/
presentation.zip
Wednesday, March 4, 2009
![Page 3: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/3.jpg)
CoreAnimation
Wednesday, March 4, 2009
![Page 4: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/4.jpg)
Background
Wednesday, March 4, 2009
![Page 5: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/5.jpg)
Background
2005
Wednesday, March 4, 2009
![Page 6: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/6.jpg)
Background
2007
2005
Wednesday, March 4, 2009
![Page 7: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/7.jpg)
Background
20082007
2005
Wednesday, March 4, 2009
![Page 8: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/8.jpg)
Wednesday, March 4, 2009
![Page 9: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/9.jpg)
Wednesday, March 4, 2009
![Page 10: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/10.jpg)
Wednesday, March 4, 2009
![Page 11: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/11.jpg)
What is Animation?
Wednesday, March 4, 2009
![Page 12: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/12.jpg)
Wednesday, March 4, 2009
![Page 13: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/13.jpg)
Wednesday, March 4, 2009
![Page 14: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/14.jpg)
Coded Animation
Wednesday, March 4, 2009
![Page 15: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/15.jpg)
Coded AnimationApply a
rule
Wednesday, March 4, 2009
![Page 16: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/16.jpg)
Coded AnimationApply a
rule
Change something
Wednesday, March 4, 2009
![Page 17: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/17.jpg)
Coded AnimationApply a
rule
Change something
Updatethe screen
Wednesday, March 4, 2009
![Page 18: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/18.jpg)
Coded AnimationApply a
rule
Change something
Updatethe screen
Wednesday, March 4, 2009
![Page 19: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/19.jpg)
Make somethingto move
Wednesday, March 4, 2009
![Page 20: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/20.jpg)
Make somethingto move
Wednesday, March 4, 2009
![Page 21: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/21.jpg)
Make somethingto move
(project files: Animation101)
Wednesday, March 4, 2009
![Page 22: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/22.jpg)
// interfaceUIImageView *ball;
// viewDidLoadball = [[UIImageView alloc] initWithImage: [UIImage imageNamed:@"ball.png"]];[self.view addSubview:ball];
Wednesday, March 4, 2009
![Page 23: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/23.jpg)
NSTimer
Wednesday, March 4, 2009
![Page 24: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/24.jpg)
NSTimer[NSTimer scheduledTimerWithTimeInterval:1.0/60.0 target:self selector:@selector(onTimer) userInfo:nil repeats:YES];
Wednesday, March 4, 2009
![Page 25: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/25.jpg)
Moving UIViews
Wednesday, March 4, 2009
![Page 26: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/26.jpg)
Moving UIViews
• view.center
Wednesday, March 4, 2009
![Page 27: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/27.jpg)
Moving UIViews
• view.center
• view.transform
Wednesday, March 4, 2009
![Page 28: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/28.jpg)
Moving UIViews
• view.center
• view.transform
• view.frame
Wednesday, March 4, 2009
![Page 29: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/29.jpg)
// interfacefloat x;float y;
// viewDidLoadx = 50.0;y = 50.0;
Wednesday, March 4, 2009
![Page 30: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/30.jpg)
ball.center = CGPointMake(x, y);x += 2.0;y += 3.0;
Wednesday, March 4, 2009
![Page 31: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/31.jpg)
ball.frame = CGRectMake(x, y, width, height);x += 2.0;y += 3.0;
Wednesday, March 4, 2009
![Page 32: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/32.jpg)
ball.transform = CGAffineTransformMakeTranslation(x, y);x += 2.0;y += 3.0;
Wednesday, March 4, 2009
![Page 33: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/33.jpg)
ball.transform = CGAffineTransformTranslate( ball.transform, 2.0, 3.0);
Wednesday, March 4, 2009
![Page 34: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/34.jpg)
Which is fastest?
Wednesday, March 4, 2009
![Page 35: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/35.jpg)
Which is fastest?
• view.center
Wednesday, March 4, 2009
![Page 36: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/36.jpg)
Which is fastest?
• view.center
• view.transform (~2-3x)
Wednesday, March 4, 2009
![Page 37: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/37.jpg)
Which is fastest?
• view.center
• view.transform (~2-3x)
• view.frame (~2-3x)
Wednesday, March 4, 2009
![Page 38: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/38.jpg)
Velocity
(project files: Velocity)
Wednesday, March 4, 2009
![Page 39: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/39.jpg)
Velocity
+(project files: Velocity)
Wednesday, March 4, 2009
![Page 40: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/40.jpg)
speedand
direction
Wednesday, March 4, 2009
![Page 41: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/41.jpg)
speedand
direction
x velocity
y velocity
Wednesday, March 4, 2009
![Page 42: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/42.jpg)
+ x velocity- x velocity
- y velocity
+ y velocity
Wednesday, March 4, 2009
![Page 43: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/43.jpg)
Wednesday, March 4, 2009
![Page 44: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/44.jpg)
// interface:float vx;float vy;
Wednesday, March 4, 2009
![Page 45: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/45.jpg)
// interface:float vx;float vy;
// viewDidLoad:vx = 2.0;vy = 3.0;
Wednesday, March 4, 2009
![Page 46: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/46.jpg)
// interface:float vx;float vy;
// viewDidLoad:vx = 2.0;vy = 3.0;
// onTimer:ball.center = CGPointMake(x, y);x += vx;y += vy;
Wednesday, March 4, 2009
![Page 47: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/47.jpg)
speed
angle
(project files: AngularVelocity)
Wednesday, March 4, 2009
![Page 48: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/48.jpg)
speed
x velocity = cos(angle) x speed
y velocity=
sin(angle)x
speed
angle
(project files: AngularVelocity)
Wednesday, March 4, 2009
![Page 49: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/49.jpg)
Wednesday, March 4, 2009
![Page 50: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/50.jpg)
// interface:float angle;float speed;
Wednesday, March 4, 2009
![Page 51: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/51.jpg)
// interface:float angle;float speed;
// viewDidLoad:angle = 45.0;speed = 4.0;
Wednesday, March 4, 2009
![Page 52: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/52.jpg)
// interface:float angle;float speed;
// viewDidLoad:angle = 45.0;speed = 4.0;
// onTimer:ball.center = CGPointMake(x, y);x += cos(angle * M_PI / 180.0) * speed;y += sin(angle * M_PI / 180.0) * speed;
Wednesday, March 4, 2009
![Page 53: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/53.jpg)
Acceleration
(project files: Acceleration)
Wednesday, March 4, 2009
![Page 54: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/54.jpg)
Acceleration
+(project files: Acceleration)
Wednesday, March 4, 2009
![Page 55: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/55.jpg)
Wednesday, March 4, 2009
![Page 56: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/56.jpg)
// interface:float ax;float ay;
Wednesday, March 4, 2009
![Page 57: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/57.jpg)
// interface:float ax;float ay;
// viewDidLoad:ax = 0.07;ay = 0.1;
Wednesday, March 4, 2009
![Page 58: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/58.jpg)
// interface:float ax;float ay;
// viewDidLoad:ax = 0.07;ay = 0.1;
// onTimer:ball.center = CGPointMake(x, y);x += vx;y += vy;vx += ax;vy += ay;
Wednesday, March 4, 2009
![Page 59: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/59.jpg)
Bouncing
(project files: Bouncing)
Wednesday, March 4, 2009
![Page 60: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/60.jpg)
Wednesday, March 4, 2009
![Page 61: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/61.jpg)
x velocity
-x velocity
y velocity
y velocity
Wednesday, March 4, 2009
![Page 62: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/62.jpg)
Wednesday, March 4, 2009
![Page 63: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/63.jpg)
// interface:float bounce;
Wednesday, March 4, 2009
![Page 64: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/64.jpg)
// interface:float bounce;
// viewDidLoad:bounce = -1.0;
Wednesday, March 4, 2009
![Page 65: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/65.jpg)
ball.center = CGPointMake(x, y); x += vx;y += vy;if(x > 300) // 320 - radius (20){ x = 300; vx *= bounce;}else if(x < 20) // 0 + radius{ x = 20; vx *= bounce;}
Wednesday, March 4, 2009
![Page 66: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/66.jpg)
if(y > 440) // 460 - radius{ y = 440; vy *= bounce;}else if(y < 20) // 0 + radius{ y = 20; vy *= bounce;}
Wednesday, March 4, 2009
![Page 67: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/67.jpg)
Gravity
acceleration(+y)
Wednesday, March 4, 2009
![Page 68: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/68.jpg)
Wednesday, March 4, 2009
![Page 69: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/69.jpg)
// interface:float gravity;
Wednesday, March 4, 2009
![Page 70: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/70.jpg)
// interface:float gravity;
// viewDidLoad:gravity = 0.5;
Wednesday, March 4, 2009
![Page 71: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/71.jpg)
// interface:float gravity;
// viewDidLoad:gravity = 0.5;
// onTimer:vy += gravity;
Wednesday, March 4, 2009
![Page 72: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/72.jpg)
Wednesday, March 4, 2009
![Page 73: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/73.jpg)
acceleration.y
acceleration.x
Wednesday, March 4, 2009
![Page 74: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/74.jpg)
@interface GravityViewController : UIViewController <UIAccelerometerDelegate>{ UIImageView *ball; float x; float y; float vx; float vy; float bounce; CGPoint gravity;}
Wednesday, March 4, 2009
![Page 75: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/75.jpg)
Wednesday, March 4, 2009
![Page 76: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/76.jpg)
// viewDidLoadgravity = CGPointZero;[[UIAccelerometer sharedAccelerometer] setDelegate:self];
Wednesday, March 4, 2009
![Page 77: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/77.jpg)
// viewDidLoadgravity = CGPointZero;[[UIAccelerometer sharedAccelerometer] setDelegate:self];
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{ gravity = CGPointMake(acceleration.x, -acceleration.y);}
Wednesday, March 4, 2009
![Page 78: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/78.jpg)
// viewDidLoadgravity = CGPointZero;[[UIAccelerometer sharedAccelerometer] setDelegate:self];
- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration{ gravity = CGPointMake(acceleration.x, -acceleration.y);}
// onTimervx += gravity.x;vy += gravity.y;
Wednesday, March 4, 2009
![Page 79: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/79.jpg)
Do we still have time?
Wednesday, March 4, 2009
![Page 80: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/80.jpg)
Dragging and Throwing
Wednesday, March 4, 2009
![Page 81: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/81.jpg)
Wednesday, March 4, 2009
![Page 82: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/82.jpg)
// interfaceBOOL dragging;
Wednesday, March 4, 2009
![Page 83: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/83.jpg)
// interfaceBOOL dragging;
// viewDidLoaddragging = NO;
Wednesday, March 4, 2009
![Page 84: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/84.jpg)
// interfaceBOOL dragging;
// viewDidLoaddragging = NO;
- (void)onTimer{ if(!dragging) { ... }}
Wednesday, March 4, 2009
![Page 85: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/85.jpg)
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{ UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self.view]; float dx = point.x - x; float dy = point.y - y; float dist = sqrt(dx * dx + dy * dy); if(dist < 20) { dragging = YES; x = point.x; y = point.y; vx = 0; vy = 0; }}
Wednesday, March 4, 2009
![Page 86: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/86.jpg)
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{ dragging = NO;}
Wednesday, March 4, 2009
![Page 87: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/87.jpg)
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ if(dragging) { UITouch *touch = [touches anyObject]; CGPoint point = [touch locationInView:self.view]; vx = point.x - x; vy = point.y - y; x = point.x; y = point.y; ball.center = point; }}
Wednesday, March 4, 2009
![Page 88: Making things Move on the iPhone](https://reader033.fdocuments.in/reader033/viewer/2022060110/555a0a58d8b42a76498b45ba/html5/thumbnails/88.jpg)
Thank you
• Keith Peters
• www.bit-101.com
• www.wickedpissahgames.com
• www.bit-101.com/360iDev/presentation.zip
Wednesday, March 4, 2009