当前位置: 首页>>代码示例>>C++>>正文


C++ Link::Activate方法代码示例

本文整理汇总了C++中Link::Activate方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::Activate方法的具体用法?C++ Link::Activate怎么用?C++ Link::Activate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Link的用法示例。


在下文中一共展示了Link::Activate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

	Tilemap(const TilemapTemplate &aTemplate, unsigned int aId)
		: mId(aId)
	{
		Entity *entity = Database::entity.Get(aId);
		Transform2 transform = entity ? entity->GetTransform() : Transform2::Identity();

		mInstance = static_cast<unsigned int *>(malloc(aTemplate.mCount * sizeof(unsigned int)));
		mCount = aTemplate.mCount;

		for (size_t i = 0; i < mCount; ++i)
		{
			const Tile &tile = aTemplate.mMap[i];
			const Transform2 spawn(tile.mOffset * transform);

			mInstance[i] = Database::Instantiate(tile.mSpawn, mId, mId, spawn.a, spawn.p);

			if (mId)
			{
				// link it (HACK)
				Database::Typed<LinkTemplate> &linktemplates = Database::linktemplate.Open(mId);
				LinkTemplate &linktemplate = linktemplates.Open(mInstance[i]);
				linktemplate.mOffset = tile.mOffset;
				linktemplate.mSub = mInstance[i];
				linktemplate.mSecondary = mInstance[i];
				Link *link = new Link(linktemplate, mId);
				linktemplates.Close(mInstance[i]);
				Database::linktemplate.Close(mId);
				Database::Typed<Link *> &links = Database::link.Open(mId);
				links.Put(mInstance[i], link);
				Database::link.Close(mId);

#if 0
				// if linking two collidables
				if (Database::collidabletemplate.Find(mId) &&
					Database::collidabletemplate.Find(mInstance[i]))
				{
					// if updating position
					if (linktemplate.mUpdatePosition)
					{
						// add a revolute joint to the linked template (HACK)
						CollidableTemplate &collidable = Database::collidabletemplate.Open(mInstance[i]);
						collidable.SetupLinkJoint(linktemplate, aId, mInstance[i]);
						Database::collidabletemplate.Close(mInstance[i]);
					}
				}
				// else if updating angle or position...
				else if (linktemplate.mUpdateAngle || linktemplate.mUpdatePosition)
#endif
				{
					// activate link update
					link->Activate();
				}
			}
		}
	}
开发者ID:Fissuras,项目名称:videoventure,代码行数:55,代码来源:Tilemap.cpp

示例2: Update


//.........这里部分代码省略.........

			if (weapon.mRecoil)
			{
				// apply recoil force
				for (unsigned int id = mId; id != 0; id = Database::backlink.Get(id))
				{
					if (Collidable *collidable = Database::collidable.Get(id))
					{
						collidable->GetBody()->ApplyImpulse(transform.Rotate(Vector2(0, -weapon.mRecoil)), transform.p);
						break;
					}
				}
			}

			if (weapon.mFlash)
			{
				// instantiate a flash
				unsigned int flashId = Database::Instantiate(weapon.mFlash, Database::owner.Get(mId), mId,
					transform.Angle(), transform.p, entity->GetVelocity(), entity->GetOmega());

				// set fractional turn
				if (Renderable *renderable = Database::renderable.Get(flashId))
					renderable->SetFraction(mTimer / aStep);

				// link it (HACK)
				LinkTemplate linktemplate;
				linktemplate.mOffset = weapon.mOffset;
				linktemplate.mSub = flashId;
				linktemplate.mSecondary = flashId;
				Link *link = new Link(linktemplate, mId);
				Database::Typed<Link *> &links = Database::link.Open(mId);
				links.Put(flashId, link);
				Database::link.Close(mId);
				link->Activate();
			}

			if (weapon.mOrdnance)
			{
				// TO DO: consolidate this with similar spawn patterns (Graze, Spawner)

				// apply position scatter
				position.a += Random::Value(0.0f, weapon.mScatter.a);
				position.p.x += Random::Value(0.0f, weapon.mScatter.p.x);
				position.p.y += Random::Value(0.0f, weapon.mScatter.p.y);

				// get world position
				position *= basetransform;

				// get local velocity
				Transform2 velocity(entity->GetOmega(), position.Unrotate(entity->GetVelocity()));

				// apply velocity inherit
				velocity.a *= weapon.mInherit.a;
				velocity.p.x *= weapon.mInherit.p.x;
				velocity.p.y *= weapon.mInherit.p.y;

				// apply velocity add
				velocity.a += weapon.mVelocity.a;
				velocity.p.x += weapon.mVelocity.p.x;
				velocity.p.y += weapon.mVelocity.p.y;

				// apply velocity variance
				velocity.a += Random::Value(0.0f, weapon.mVariance.a);
				velocity.p.x += Random::Value(0.0f, weapon.mVariance.p.x);
				velocity.p.y += Random::Value(0.0f, weapon.mVariance.p.y);
开发者ID:Fissuras,项目名称:videoventure,代码行数:66,代码来源:WeaponOriginal.cpp


注:本文中的Link::Activate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。