[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/bbcode.php on line 488: preg_replace(): The /e modifier is no longer supported, use preg_replace_callback instead
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4762: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4764: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4765: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
[phpBB Debug] PHP Warning: in file [ROOT]/includes/functions.php on line 4766: Cannot modify header information - headers already sent by (output started at [ROOT]/includes/functions.php:3897)
Chipmunk Physics • View topic - cpSpaceEachBody

cpSpaceEachBody

Official forum for the .

cpSpaceEachBody

Postby cjung89 » Wed Jun 10, 2009 3:07 pm

I am having trouble using this function properly, particularly the 'data' parameter.

I create a function
void move (cpBody* b, CGPoint l){
b->p = l;
}

then call

cpSpaceEachBody(space, &move, &Location) where Location is a CGPoint acquired from touch event.

I receive a warning "passing argument 2 of 'cpSpaceEachBody' from incompatible pointer type, although the move function does get called. It sets the position to (0,0). How do I change the move function or my call to cpSpaceEachBody to get the desired outcome?
cjung89
 
Posts: 5
Joined: Mon Jun 08, 2009 7:46 pm

Re: cpSpaceEachBody

Postby slembcke » Wed Jun 10, 2009 11:30 pm

First of all, you CANNOT use CGPoints interchangeably with cpVects. That is going to cause problems, several people have had problems already that have been fixed by not trying to use CGPoints as cpVects.

Second, the type of your function is not the same as the type because the last parameter is void *. You either need to cast the function pointer or change the second argument type to void * and cast the value inside.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
User avatar
slembcke
Site Admin
 
Posts: 4164
Joined: Tue Aug 14, 2007 7:13 pm

Re: cpSpaceEachBody

Postby cjung89 » Wed Jun 10, 2009 11:51 pm

Thanks for the response Slembcke. I am new to Objective C and am not too familiar with this style of function passing. Reading this forum is helping alot.
cjung89
 
Posts: 5
Joined: Mon Jun 08, 2009 7:46 pm

Re: cpSpaceEachBody

Postby cjung89 » Thu Jun 11, 2009 2:20 pm

As a follow up to my last question:
if I define "move" like so:

void move(cpBody* b, cpVect* l){
b->p = *l
}

and I call cpSpaceEachBody like so:

cpSpaceEachBody(space, move, &Location);

I get the desired performance with a warning "passing argument 2 of 'cpSpaceEachBody' from incompatible pointer type".
I get the same performance if I preface the 'move' argument with &. Does anyone know how specifically I can get rid of this warning and get the desired result?
cjung89
 
Posts: 5
Joined: Mon Jun 08, 2009 7:46 pm

Re: cpSpaceEachBody

Postby cjung89 » Thu Jun 11, 2009 2:43 pm

Nevermind. All I had to do was cast the pointer, like you said. (void *)move
cjung89
 
Posts: 5
Joined: Mon Jun 08, 2009 7:46 pm


Return to Chipmunk2D Physics

Who is online

Users browsing this forum: No registered users and 3 guests

cron