bool Hero::initWithWorld(b2World * w) { setSprite(CCSprite::create("hero.png")); addChild(getSprite()); world = w; radius = 16.0f; awake = false; createBox2DBody(); updateNodePosition(); sleep(); return true; }
bool Hero::initWithWorld(b2World * w) { //initWithFile("hero.png"); setSprite(CCSprite::create("hero.png")); addChild(getSprite()); world = w; radius = 16.0f; awake = false; /* CCSize size = CCDirector::sharedDirector()->getWinSize(); // int screenW = size.width; int screenH = size.height; CCPoint startPosition = ccp(0, screenH/2+radius); b2BodyDef bd; bd.type = b2_dynamicBody; //bd.position.Set(screenW/4/PTM_RATIO, screenH/2/PTM_RATIO); bd.linearDamping = 0.1f; bd.fixedRotation = true; bd.position.Set(startPosition.x/PTM_RATIO, startPosition.y/PTM_RATIO); body = world->CreateBody(&bd); b2CircleShape shape; shape.m_radius = radius/PTM_RATIO; b2FixtureDef fd; fd.shape = &shape; fd.density = 1.0f; fd.restitution = 0.0f; // 0 - no bounce, 1 - perfect bounce fd.friction = 0; body->CreateFixture(&fd); */ createBox2DBody(); updateNodePosition(); sleep(); return true; }