Пример #1
0
void HSBalloonSprite::Rest()
{
	m_fScale = 1.f;
	DeactivateCollisions();
	getB2Body()->SetType(b2_staticBody);
	this->setPosition(ccp(this->getContentSize().width + 100.f,-800.f));
}
Пример #2
0
void Opponent::update (float dt)
{
    // In case the opponent suppose to stop, reduce the velocity. Otherwise the velocity will be adjusted from the network events.
    if (_state == kOpponentStopped) {
        b2Body* playerBody = getB2Body();
        playerBody->SetLinearVelocity(b2Vec2(0,0));
    }
}
Пример #3
0
void Steven::update( float delta )
{
	//keep speed 
	b2Body* body = getB2Body();
	b2Vec2 v = body->GetLinearVelocity();
	b2Vec2 impulse = skiSpeed(v);
	impulse *= body->GetMass();
	//b2Vec2 impulse = b2Vec2( (10 - v.x)*body->GetMass(), 0);
	body->ApplyLinearImpulse(impulse, body->GetWorldCenter());

	////compute distance to hill
	b2Vec2 rayStart = this->m_pB2Body->GetWorldCenter();
	b2Vec2 rayEnd = b2Vec2(rayStart.x, rayStart.y - 100);
	class RayCastCallback : public b2RayCastCallback
	{
		virtual float32 ReportFixture(b2Fixture* fixture, const b2Vec2& point, const b2Vec2& normal, float32 fraction)
		{
			CCString* name = b2Helper::getBodyName(fixture->GetBody());
			if (name->compare("hill") == 0)
			{
				Steven* steven = Steven::sharedSteven();
				steven->mSkiHigh = (steven->m_pB2Body->GetWorldCenter().y - point.y) * G.PTM_RATIO - mRadius;
				return 0;
			}
			return 1;
		}
	} callback;
	G.world->RayCast(&callback,rayStart, rayEnd);

	//auto rotation in sky
	if (flying())
	{
		rotationBy(-30 * delta);
	}
	if (flying() && mStatus == StevenStatus::SS_Ski)
	{
		fly();
	}
}
Пример #4
0
Steven::~Steven()
{
	b2Helper::destroyBody(getB2Body());
}