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


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

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


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

示例1: render

void StaticBox::render(SpriteBatch & spriteBatch)
{
	glm::vec4 destRect;
	destRect.x = _position.x - _dimension.x;
	destRect.y = _position.y - _dimension.y;
	destRect.z = _dimension.x * 2.0f;
	destRect.w = _dimension.y * 2.0f;
	spriteBatch.addToBatch(destRect, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), 2.0f, _texture.id, Color(_brightness, _brightness, _brightness, 255));
}
开发者ID:ConnorShore,项目名称:Game,代码行数:9,代码来源:StaticBox.cpp

示例2: render

void Box::render(SpriteBatch& spriteBatch)
{
	glm::vec4 destRect;
	destRect.x = _body->GetPosition().x - _dimension.x / 2.0f;
	destRect.y = _body->GetPosition().y - _dimension.y / 2.0f;
	destRect.z = _dimension.x;
	destRect.w = _dimension.y;

	spriteBatch.addToBatch(destRect, _uvRect, 2.0f, _texture.id, Color(_brightness, _brightness, _brightness, 255), _body->GetAngle());
}
开发者ID:ConnorShore,项目名称:Game,代码行数:10,代码来源:Box.cpp

示例3: render

void Block::render(SpriteBatch & spriteBatch)
{
	glm::vec4 destRect;
	glm::vec2 position(_staticBox.getPosition().x, _staticBox.getPosition().y);

	destRect.x = position.x - _size / 2.0f;
	destRect.y = position.y - _size / 2.0f;
	destRect.z = _size;
	destRect.w = _size;

	spriteBatch.addToBatch(destRect, glm::vec4(0.0f, 0.0f, 1.0f, 1.0f), _depth, _texture.id, Color(_brightness, _brightness, _brightness, 255));
}
开发者ID:ConnorShore,项目名称:Game,代码行数:12,代码来源:Block.cpp

示例4: render

void Player::render(SpriteBatch & spriteBatch)
{
	glm::vec4 destRect;
	b2Body* body = _collisionBox.getBody();
	destRect.x = body->GetPosition().x - _drawDim.x / 2.0f;
	destRect.y = body->GetPosition().y - _drawDim.y / 2.0f;
	destRect.z = _drawDim.x;
	destRect.w = _drawDim.y;

	glm::vec2 velocity(body->GetLinearVelocity().x, body->GetLinearVelocity().y);

	//Calculate animation
	int tileIndex, numTiles;
	float animationSpeed = 0.2f;

	if (_onGround) {
		
		if (abs(velocity.x) > 1.0f) {
			//Running
			tileIndex = 1;
			numTiles = 6;
			animationSpeed = abs(velocity.x) * 0.025f;

			if (_moveState != PlayerMoveState::RUNNING) {
				_moveState = PlayerMoveState::RUNNING;
				_animTime = 0.0f;
			}
		}
		else {
			//Standing
			numTiles = 1;
			tileIndex = 0;
			_moveState = PlayerMoveState::STANDING;
		}
	}
	else {
		//Falling or Jumping
		numTiles = 1;
		tileIndex = 7;
		_moveState = PlayerMoveState::IN_AIR;
	}

	//Increment animation speed;
	_animTime += animationSpeed;

	//Stop animation loop
	if (_animTime > numTiles) {
		_attacking = false;
	}

	//Apply animation
	tileIndex = tileIndex + (int)_animTime % numTiles;

	glm::vec4 uvRect = _texture.getUVs(tileIndex);

	//Flip UVs if player is going left
	if (_direction == -1) {
		uvRect.x += 1.0f / _texture.dims.x;
		uvRect.z *= -1;
	}

	spriteBatch.addToBatch(destRect, uvRect, 0.0f, _texture.texture.id, Color(_brightness, _brightness, _brightness, 255), body->GetAngle());
}
开发者ID:ConnorShore,项目名称:Game,代码行数:63,代码来源:Player.cpp


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