mirror of https://github.com/axmolengine/axmol.git
give a guide information to run Box2dTest
This commit is contained in:
parent
735815240a
commit
8063b9b9fb
|
@ -11,7 +11,9 @@ enum {
|
|||
|
||||
Box2DTestLayer::Box2DTestLayer()
|
||||
: m_pSpriteTexture(NULL)
|
||||
, world(NULL)
|
||||
{
|
||||
#if CC_ENABLE_BOX2D_INTEGRATION
|
||||
setTouchEnabled( true );
|
||||
setAccelerometerEnabled( true );
|
||||
|
||||
|
@ -41,12 +43,20 @@ Box2DTestLayer::Box2DTestLayer()
|
|||
label->setPosition(ccp( VisibleRect::center().x, VisibleRect::top().y-50));
|
||||
|
||||
scheduleUpdate();
|
||||
#else
|
||||
CCLabelTTF *pLabel = CCLabelTTF::create("Should define CC_ENABLE_BOX2D_INTEGRATION\n to run this test case",
|
||||
"Arial",
|
||||
18);
|
||||
CCSize size = CCDirector::sharedDirector()->getWinSize();
|
||||
pLabel->setPosition(ccp(size.width/2, size.height/2));
|
||||
|
||||
addChild(pLabel);
|
||||
#endif
|
||||
}
|
||||
|
||||
Box2DTestLayer::~Box2DTestLayer()
|
||||
{
|
||||
delete world;
|
||||
world = NULL;
|
||||
CC_SAFE_DELETE(world);
|
||||
|
||||
//delete m_debugDraw;
|
||||
}
|
||||
|
@ -133,6 +143,7 @@ void Box2DTestLayer::draw()
|
|||
//
|
||||
CCLayer::draw();
|
||||
|
||||
#if CC_ENABLE_BOX2D_INTEGRATION
|
||||
ccGLEnableVertexAttribs( kCCVertexAttribFlag_Position );
|
||||
|
||||
kmGLPushMatrix();
|
||||
|
@ -140,6 +151,7 @@ void Box2DTestLayer::draw()
|
|||
world->DrawDebugData();
|
||||
|
||||
kmGLPopMatrix();
|
||||
#endif
|
||||
}
|
||||
|
||||
void Box2DTestLayer::addNewSpriteAtPosition(CCPoint p)
|
||||
|
@ -165,17 +177,17 @@ void Box2DTestLayer::addNewSpriteAtPosition(CCPoint p)
|
|||
fixtureDef.friction = 0.3f;
|
||||
body->CreateFixture(&fixtureDef);
|
||||
|
||||
CCNode *parent = this->getChildByTag(kTagParentNode);
|
||||
|
||||
//We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is
|
||||
//just randomly picking one of the images
|
||||
int idx = (CCRANDOM_0_1() > .5 ? 0:1);
|
||||
int idy = (CCRANDOM_0_1() > .5 ? 0:1);
|
||||
#if CC_ENABLE_BOX2D_INTEGRATION
|
||||
CCPhysicsSprite *sprite = CCPhysicsSprite::createWithTexture(m_pSpriteTexture,CCRectMake(32 * idx,32 * idy,32,32));
|
||||
parent->addChild(sprite);
|
||||
sprite->setBody(body);
|
||||
sprite->setPTMRatio(PTM_RATIO);
|
||||
CCNode *parent = this->getChildByTag(kTagParentNode);
|
||||
|
||||
//We have a 64x64 sprite sheet with 4 different 32x32 images. The following code is
|
||||
//just randomly picking one of the images
|
||||
int idx = (CCRANDOM_0_1() > .5 ? 0:1);
|
||||
int idy = (CCRANDOM_0_1() > .5 ? 0:1);
|
||||
#if CC_ENABLE_BOX2D_INTEGRATION
|
||||
CCPhysicsSprite *sprite = CCPhysicsSprite::createWithTexture(m_pSpriteTexture,CCRectMake(32 * idx,32 * idy,32,32));
|
||||
parent->addChild(sprite);
|
||||
sprite->setBody(body);
|
||||
sprite->setPTMRatio(PTM_RATIO);
|
||||
sprite->setPosition( ccp( p.x, p.y) );
|
||||
#endif
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue