PlanetCute DEMO (ARC Help!)

General discussion about the R.U.B.E editor
Post Reply
ifMike
Posts: 6
Joined: Mon Sep 02, 2013 9:53 am

PlanetCute DEMO (ARC Help!)

Post by ifMike »

I'm trying to update the PlanetCute demo so that it compiles using ARC with cocos2d v2.1.
But I am getting a couple of (compile) errors.

• Problem 1 in PlanetCuteRUBELayer.mm (solved), just showing it if it might help others:
The first error was "Cast of C pointer type 'void *' to Objective-C pointer type 'PlanetCuteFixtureUserData *' requires a bridged cast", I solved this pretty easily:

I changed this line:

Code: Select all

 PlanetCuteFixtureUserData* fudA = (PlanetCuteFixtureUserData*)fA->GetUserData(); 
to:

Code: Select all

 PlanetCuteFixtureUserData* fudA = (__bridge PlanetCuteFixtureUserData*)fA->GetUserData(); 
• Problem 2 in PlanetCuteRUBELayer.mm (not solved):

in "-(void)afterLoadProcessing:(b2dJson*)json" I get this error:

ERROR CODE: Cannot initialize a parameter of type 'void *' with an lvalue of type 'PlanetCuteFixtureUserData *__strong'

Code: Select all

        // For every pickup fixture, we create a FixtureUserData to set in
        // the user data.
        PlanetCuteFixtureUserData* fud = [[PlanetCuteFixtureUserData alloc] init];
        [m_allPickups addObject:fud];
        f->SetUserData( fud ); // <- This is not working
		
	



• Problem 3 in PlanetCuteRUBELayer.mm (not solved):

in "-(void)afterLoadProcessing:(b2dJson*)json" I also get this error:

ERROR CODE: Assigning to 'void *' from incompatible type 'PlanetCuteRUBELayer *const __strong'

Code: Select all

		// Create a contact listener and let the Box2D world know about it.
		m_contactListener = new PlanetCuteContactListener();
		m_world->SetContactListener( m_contactListener );
    
		// Give the listener a reference to this class, to use in the callback
		m_contactListener->m_layer = self; // This is not working
		

I've googled my ass off :) Any help? :)

Any plans on updating the demos for cocos2d v.2 with arc? :)
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: PlanetCute DEMO (ARC Help!)

Post by iforce2d »

In retrospect it would have been better to make the PlanetCuteUserData a simple c-struct, which would fix those first two issues. The last one, I am not really sure about. I'm planning to re-arrange the Cocos2d sample loader to remove the cocos2d code itself, so that only the RUBE-related files remain. While I'm at it I will take a look at this as well.
Post Reply