void Barrier::CreateSelf() { if(m_created) return; if(m_Exploded) return; b2PolygonShape box; b2FixtureDef fd; b2BodyDef bd; box.SetAsBox(0.5f, 1.25f); fd.shape = &box; fd.friction = 0.62f; fd.filter.groupIndex = -1; fd.isSensor = true; bd.position.Set(m_StartPos.x, m_StartPos.y+1.25); m_MainCollision = m_world->CreateBody(&bd); m_MainCollision->CreateFixture(&fd); TextureObject *tex = NULL; tex = new TextureObject((char*)"ctm_City_Barrier_Small.png",m_ccLayer,2,true,kTexture2DPixelFormat_Default); m_MainCollision->SetUserData(tex); tex->SetTextureOffset(0.75f, 1.0f); m_Lights = CCSprite::createWithSpriteFrameName("ctm_City_Barrier_Small_Lights.png"); //m_Lights->setPosition = ccp(PTM_RATIO*(m_StartPos.x+0.75),PTM_RATIO*(m_StartPos.y+2.5f)); tex->GetSprite()->addChild(m_Lights,2); m_Exploded = false; m_created = true; m_LastFlicker = 0.2f; m_waitTime = 0.0f; }
void ExplodingBarrel::CreateSelf() { if(m_created) return; b2PolygonShape box; b2FixtureDef fd; b2BodyDef bd; box.SetAsBox(0.8f, 1.0f); fd.shape = &box; fd.friction = 0.62f; fd.filter.groupIndex = -1; fd.isSensor = true; bd.position.Set(m_StartPos.x, m_StartPos.y+1.0); m_MainCollision = m_world->CreateBody(&bd); m_MainCollision->CreateFixture(&fd); TextureObject *tex = new TextureObject((char*)"ctm_Barrel.png",m_ccLayer,1,true,kTexture2DPixelFormat_Default); m_MainCollision->SetUserData(tex); tex->SetTextureOffset(0.0f, 0.55); m_Exploded = false; }