Hi Everyone,
I'm currently developing my first iphone game.I'm using one timer to move characters from left to right. Here is my code in viewDidLoad().
arryBadBoys1 = [[NSMutableArray alloc] init];
numberOf1s=15;
thiefTag1=0;
iWalkingSpeed=2.0;
randomCreation=2.0;
iSelectedMan=100;
pos =CGPointMake(0.0,0.0);
[super viewDidLoad];
NSArray * firstGuy = [[NSArray alloc] initWithObjects:
[UIImage imageNamed:@"walk1.png"],
[UIImage imageNamed:@"walk2.png"],
[UIImage imageNamed:@"walk3.png"],
[UIImage imageNamed:@"walk4.png"],
[UIImage imageNamed:@"walk5.png"],
[UIImage imageNamed:@"walk6.png"],
[UIImage imageNamed:@"walk7.png"],
[UIImage imageNamed:@"walk8.png"],
nil];
UIImageView *imgTempMan;
for (int i=0; i<numberOf1s; i++) {
imgTempMan=[[UIImageView alloc] initWithFrame:CGRectMake(0.0, 157.0, 84.0, 128.0)];
imgTempMan.animationImages = firstGuy;
imgTempMan.animationDuration = 0.9;
imgTempMan.contentMode = UIViewContentModeBottomLeft;
[imgTempMan startAnimating];
[arryBadBoys1 addObject:imgTempMan];
[imgTempMan release];
}
[self.view addSubview:[arryBadBoys1 objectAtIndex:thiefTag1]];
runDaWorld = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(movingThieves) userInfo:nil repeats:YES];
[runDaWorld retain];
This is my code for moving these characters from left to right.
- (void)movingThieves {
for(int i=0;i<[arryBadBoys1 count];i++) {
if(i!=iSelectedMan) {
UIImageView *tempMan =[arryBadBoys1 objectAtIndex:i];
tempMan.center=CGPointMake(tempMan.center.x+iWalkingSpeed,200.0);
testCount=tempMan.frame.origin.x;
}
if(testCount== 460.0) {
healthCount++;
}
}
}
My need is to move these characters off the top right corner of my screen by flicking them towards that direction. How can I achieve that using touchesMoved Method?.
Thanks.