I spent a while on this but I don't think it requires a separate sample loader after all. It comes down to the first line you changed, where contentSizeInPixels is no longer available. It seems that v2 removes the need to use contentScaleFactor all over the place to handle the different device types. Basically, anywhere in the RUBE sample code that you see contentScaleFactor used, you can ignore it.
Specifically there are two lines that need to be changed. The first is the one you identified already:
Before:
[sprite setScale:img->scale / [sprite contentSizeInPixels].height * contentScaleFactor ];
After:
[sprite setScale:img->scale / [sprite contentSize].height ];
Actually, if you don't want to use debug draw, that's all you should need to change. If you do want to use debug draw (and I highly recommend having it available to see what's happening), you will also need to change the other place where contentScaleFactor is used, in BasicRUBELayer.mm:
Before:
m_debugDraw = new GLESDebugDraw( [[CCDirector sharedDirector] contentScaleFactor] );
After:
m_debugDraw = new GLESDebugDraw( 1 );
Of course, to actually get the debug draw rendering with the newer shader model method, you'll also need to copy the way it is done in the HelloWorldLayer from the template, but I guess you have figured that out already. In any case, I ended up with something like this:
Code: Select all
-(void) draw
{
if ( !m_world )
return;
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
kmGLPushMatrix();
m_world->DrawDebugData();
if ( m_mouseJoint ) {
b2Vec2 p1 = m_mouseJoint->GetAnchorB();
b2Vec2 p2 = m_mouseJoint->GetTarget();
b2Color c;
c.Set(0.0f, 1.0f, 0.0f);
m_debugDraw->DrawPoint(p1, 4.0f, c);
m_debugDraw->DrawPoint(p2, 4.0f, c);
c.Set(0.8f, 0.8f, 0.8f);
m_debugDraw->DrawSegment(p1, p2, c);
}
kmGLPopMatrix();
}
I understand how tricky these things can be, so thanks for sticking with it. Even when there is a 50/50 chance it's still easy to go the wrong way, and things get more confusing when you start changing places that didn't actually need to be changed, because somebody who sounded like they knew what they were talking about suggested it
