Last post here, because I've sort of hijacked the thread, but here's my code.
Code:
@implementation SiegeViewController
@synthesize maxEnemies, newBall,origin,squaretest;
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[self touchesMoved:touches withEvent:event];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:touch.view];
newBall.center = location;
}
- (void)spawn1sec
{
UIImage *enemyImage = [UIImage imageNamed:@"Green_Square.png"];
newBall = [[UIImageView alloc] initWithImage: enemyImage];
//add to array
[enemies addObject:newBall];
//add to the view, so it gets displayed.
[self.view addSubview: newBall];
newBall.center = CGPointMake(1, 1);
newBall.userInteractionEnabled = YES;
}
- (void)gameLoop
{
for (newBall in enemies)
{
int newX = newBall.center.x;
int newY = newBall.center.y +1;
newBall.center = CGPointMake(newX, newY);
}
}
This doesn't work. I want to move the newBall object to the touchpoint, but it doesn't work. I probably haven't implemented the subclass properly.
That link was useful though. I've given it a read, and I think I know how to fix my problem.