Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum

View Single Post
Old 03-29-2009, 07:15 PM   #36 (permalink)
.mb
New Member
 
Join Date: Mar 2009
Posts: 32
Default

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.
.mb is offline   Reply With Quote
 

» Advertisements
» Stats
Members: 158,868
Threads: 89,225
Posts: 380,691
Top Poster: BrianSlick (7,129)
Welcome to our newest member, stokesreece
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 06:18 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.