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 09-29-2011, 09:08 PM   #1 (permalink)
Always learning...
 
PawApps's Avatar
 
Join Date: Jul 2011
Location: USA
Posts: 46
PawApps is on a distinguished road
Default Chipmunk changing mass from STATIC_MASS

Hello,

I have a wall that is set up as follows:

Code:
cpCCSprite *wall_bottom = [cpCCSprite spriteWithFile:@"wall_bottom.png"];
    cpShape *wall_bottom_shape = [sm addRectAt:ccp(field_position.y + [wall_bottom contentSize].width/2, field_position.x) mass:STATIC_MASS width:[wall_bottom contentSize].width height:[wall_bottom contentSize].height rotation:0.0f];
    wall_bottom.shape = wall_bottom_shape;
    [self addChild:wall_bottom];
Later (after a game over) I want the wall to fall away:

Code:
cpBodySetMass([wall_bottom shape]->body, 25.0f);
The shape (invisible) falls away, but the sprite (wall_bottom) stays put on the screen. Any ideas?

Note: using SpaceManager

Thanks
__________________

PawApps.com **** Bottle Tunes **** Word Overflow

Last edited by PawApps; 09-29-2011 at 09:37 PM. Reason: fix typo
PawApps is offline   Reply With Quote
Old 10-01-2011, 10:38 AM   #2 (permalink)
Always learning...
 
PawApps's Avatar
 
Join Date: Jul 2011
Location: USA
Posts: 46
PawApps is on a distinguished road
Default

Update for anyone that may find this thread in the future and wants the solution.

I don't understand the reasons behind it, but instead of changing the mass of a shape, I removed the shape from the space and added a new shape that looked identical, same position and all, but with the only difference being it had a mass. This looked and worked very well.

Code:
[sm removeShape:[wall_bottom shape]];
    cpShape *new_shape = [sm addRectAt:[wall_bottom position] mass:25.0f width:[wall_bottom contentSize].width height:[wall_bottom contentSize].height rotation:0.0f];
    wall_bottom.shape = new_shape;
__________________

PawApps.com **** Bottle Tunes **** Word Overflow
PawApps is offline   Reply With Quote
Reply

Bookmarks

Tags
chipmunk

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: 388
11 members and 377 guests
7twenty7, apatsufas, comicool, Creativ, Dalia, dansparrow, Duncan C, HemiMG, Murphy, pbart, Tomsky
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,676
Threads: 94,127
Posts: 402,915
Top Poster: BrianSlick (7,990)
Welcome to our newest member, jleannex55
Powered by vBadvanced CMPS v3.1.0

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