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

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

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

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 04-02-2011, 02:30 AM   #1 (permalink)
Registered Member
 
Join Date: Dec 2010
Posts: 38
AlphaMensch is on a distinguished road
Default CHIPMUNK: create multiple Shapes with same Name and remove the first, second...

hi

I want to develop a game with chipmunk:
You have to draw a line before the ball falling down. And if you draw 5 lines the first should remove from the space.
My code:
Code:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
	UITouch *touch = [[event allTouches] anyObject];
	
	location1 = [touch locationInView:self.view];
	
	BEX=location1.x;
	BEY=480-location1.y;
}

- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
	UITouch *touch = [[event allTouches] anyObject];
	
	location2 = [touch locationInView:self.view];
	
	ENX=location2.x;
	ENY=480-location2.y;

	splineBody = cpBodyNew(INFINITY, INFINITY);
	splineShape = cpSegmentShapeNew(splineBody, cpv(BEX, BEY), cpv(ENX, ENY), 0);
	splineShape->e = 1; splineShape->u = 0.1; splineShape->collision_type = 0;
	cpSpaceAddStaticShape(space, splineShape);
	splineCount += 1;

	if (splineCount >= 5) {
		NSLog(@"deleted");
		cpSpaceRemoveStaticShape(space, splineShape);
	}else {
		NSLog(@"newShape");
		NSLog(@"%i,%i,%i,%i",BEX,BEY,ENX,ENY);
	}	
		
}
But if I do this it remove the Line i draw at the moment. So I cant draw a new line.
Is there a way to do that?

AlphaMensch
AlphaMensch is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 433
7 members and 426 guests
chemistry, Emy, hussain1982, mistergreen2011, Retouchable, skrew88, SLIC
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,922
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:15 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0