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


C++ SpriteBatch::Draw方法代码示例

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


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

示例1: draw

 void SpriteFont::draw(SpriteBatch& batch, const char* s, glm::vec2 position, glm::vec2 scaling, 
                       float depth, ColorRGBA8 tint, Justification just /* = Justification::LEFT */) {
     glm::vec2 tp = position;
     // Apply justification
     if (just == Justification::MIDDLE) {
         tp.x -= measure(s).x * scaling.x / 2;
     } else if (just == Justification::RIGHT) {
         tp.x -= measure(s).x * scaling.x;
     }
     for (int si = 0; s[si] != 0; si++) {
         char c = s[si];
         if (s[si] == '\n') {
             tp.y += _fontHeight * scaling.y;
             tp.x = position.x;
         } else {
             // Check for correct glyph
             int gi = c - _regStart;
             if (gi < 0 || gi >= _regLength)
                 gi = _regLength;
             glm::vec4 destRect(tp, _glyphs[gi].size * scaling);
             batch.Draw(destRect, _glyphs[gi].uvRect, _texID, depth, tint);
             tp.x += _glyphs[gi].size.x * scaling.x;
         }
     }
 }
开发者ID:SimpleManGames,项目名称:ZombieGame,代码行数:25,代码来源:SpriteFont.cpp

示例2: Draw

void RagdollCharacter::Draw(SpriteBatch& _spriteBatch) {
	// Loop through and draw the bodies
	for (int i = 0; i < bodies.size(); i++) {
		b2Vec2 positionMetres = GetBody(i)->GetPosition();
		float widthMetres = 0.5F, heightMetres = 0.5F;
		// Scale it to 100 pixels per metre
		if (GetBody(i)->GetFixtureList()->GetShape()->GetType() == b2Shape::e_circle)
		{
			widthMetres = GetBody(i)->GetFixtureList()->GetShape()->m_radius * 2;
			heightMetres = GetBody(i)->GetFixtureList()->GetShape()->m_radius * 2;

			glm::vec4 destRect(positionMetres.x * 100, positionMetres.y * 100, widthMetres * 100, heightMetres * 100);
			glm::vec4 uv(0.0F, 0.0F, 1.0F, 1.0F);
			Color color;

			_spriteBatch.Draw(destRect, uv, headTexture.id, 0.0F, GetBody(i)->GetAngle(), color);
			_spriteBatch.Draw(destRect, uv, headHappyTexture.id, 0.0F, GetBody(i)->GetAngle(), color);
		}

		else if(GetBody(i)-> GetFixtureList()->GetShape()->GetType() == b2Shape::e_polygon)
		{
			b2PolygonShape* shape = (b2PolygonShape*)GetBody(i)->GetFixtureList()->GetShape();

			widthMetres = shape->GetVertex(0).x * 2;
			heightMetres = shape->GetVertex(0).y * 2;

			glm::vec4 destRect(positionMetres.x * 100, positionMetres.y * 100, widthMetres * 100, heightMetres * 100);
			glm::vec4 uv(0.0F, 0.0F, 1.0F, 1.0F);
			Color color;

			_spriteBatch.Draw(destRect, uv, boxTexture.id, 0.0F, GetBody(i)->GetAngle(), color);
		}


	}
}
开发者ID:PavanJakhu,项目名称:Dire-Dungeon,代码行数:36,代码来源:RagdollCharacter+(1).cpp

示例3: Draw

	virtual void Draw() override
	{
		GetGraphicsDevice().Clear(Color4::White);
		spriteBatch.Begin(BlendState::AlphaBlend);

		for (int i = 0; i < blipCount; i++)
		{
			spriteBatch.Draw(ball, blips[i], scale, origin);
		}

		theta += 0.01f;

		Game::Draw();
		spriteBatch.End();
	}
开发者ID:TCooper8,项目名称:KetaGLFramework,代码行数:15,代码来源:Main.cpp

示例4: Draw

void ListBox::Draw( SpriteBatch& spriteBatch, SpriteBatch& spriteBatchFont )
{
	if (!mVisible)
		return;

	int2 screenPos = GetScreenPosition();

	float zOrder = GetDepthLayer();

	// Draw background first
	Rectanglef backRC((float)screenPos.X(), (float)screenPos.Y(), (float)mSize.X(), (float)mSize.Y());
	mLisBoxStyle->DrawNinePatch(spriteBatch, UI_State_Normal, backRC, zOrder);

	if (mItems.size())
	{
		int mimItem, maxItem;
		mVertScrollBar->GetScrollRange(&mimItem, &maxItem);

		Rectanglef rc((float)mTextRegion.X, (float)mTextRegion.Y, (float)mTextRegion.Width, (float)mTextRegion.Height);
		rc.SetBottom( rc.Y + mTextRowHeight);

		for (int i = mVertScrollBar->GetScrollValue(); i < maxItem + mNumVisibleItems; ++i)
		{		
			if (rc.Bottom() > (float)mTextRegion.Bottom())
				break;

			if( i == mSelectedIndex )
			{
				// Draw selected highlight
				Rectanglef rcSel;

				rcSel.SetLeft(mSelectionRegion.Left()+1);
				rcSel.SetRight(mSelectionRegion.Right());
				rcSel.SetTop((float)rc.Top());
				rcSel.SetBottom((float)rc.Bottom());
				
				spriteBatch.Draw(mLisBoxStyle->StyleTex, rcSel, &mLisBoxStyle->StyleStates[UI_State_Hover].TexRegion,
					mLisBoxStyle->StyleStates[UI_State_Hover].TexColor, zOrder);
			}

			// draw text
			//Rectanglef region((float)rc.X, (float)rc.Y, (float)rc.Width, (float)rc.Height);
			mLisBoxStyle->Font->DrawString(spriteBatchFont, mItems[i], mLisBoxStyle->FontSize, AlignVCenter, rc, mLisBoxStyle->ForeColor, zOrder);

			rc.Offset(0, mTextRowHeight);
		}
	}
}
开发者ID:Joke-Dk,项目名称:RcEngine,代码行数:48,代码来源:ListBox.cpp

示例5: Draw

void TopLayer::Draw(const GameTime& gameTime, SpriteBatch& spriteBatch) {
	
	Point cameraPt = Camera2D::getCell();
	
	Point viewPt = Point::toCell((Vector2) {
		Camera2D::getPosition().x + Camera2D::getViewPort().width,
		Camera2D::getPosition().y + Camera2D::getViewPort().height
	});
	
	Point min = (Point) {
		std::max((ChunkLength - 1) * _cellPosition.x, cameraPt.x - 1),
		std::max((ChunkLength - 1) * _cellPosition.y , cameraPt.y - 1)
	};
	Point max = (Point) {
		std::min(viewPt.x + 1, (ChunkLength - 1) * (_cellPosition.x + 1)),
		std::min(viewPt.y + 1, (ChunkLength - 1) * (_cellPosition.y + 1))
	};

	// if(max.x <= 0 || max.y <= 0 || min.x >= ChunkLength || min.y >= ChunkLength)
	// return;
	
	Tile tile;
	Rectangle destination = (Rectangle) {0, 0, TileLength, TileLength};
	
	for(register int y = min.y; y < max.y; y++) {
		
		for(register int x = min.x; x < max.x; x++) {
			
			tile = getTile(x - (ChunkLength - 1) * _cellPosition.x, y - (ChunkLength - 1) * _cellPosition.y);
			
			
			
			if(tile.getTileSet() == -1 || tile.getIndex() == -1)
				continue;
			
			destination.x = x * TileLength;
			destination.y = y * TileLength;
			
			spriteBatch.Draw(
				*((_tileSets.get() + tile.getTileSet())->getTexture()),
				(_tileSets.get() + tile.getTileSet())->getSourceRec(tile.getIndex()),
				destination, (Vector2){0.0f, 0.0f}, 0.0f, WHITE);
		}
		
	}
	
}
开发者ID:komatura,项目名称:Bengite,代码行数:47,代码来源:TopLayer.cpp

示例6: Draw

void Sprite::Draw(SpriteBatch& batch)
{
	batch.Draw(*this);
}
开发者ID:Zammalad,项目名称:ZEGL,代码行数:4,代码来源:sprite.cpp


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