本文整理汇总了C++中TextureHolder类的典型用法代码示例。如果您正苦于以下问题:C++ TextureHolder类的具体用法?C++ TextureHolder怎么用?C++ TextureHolder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TextureHolder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Entity
Tile::Tile(Type type, const TextureHolder& textures)
: Entity(1)
, mType(type)
, mSprite(textures.get(Table[type].texture), Table[type].textureRect)
, mExplosion(textures.get(Textures::Explosion))
, mDropPickupCommand()
, mShowExplosion(false)
, mSpawnedPickup(false)
, mPickupsEnabled(true)
{
mExplosion.setFrameSize(sf::Vector2i(256, 256));
mExplosion.setNumFrames(16);
mExplosion.setDuration(sf::seconds(1));
centerOrigin(mSprite);
centerOrigin(mExplosion);
mDropPickupCommand.category = Category::SceneFieldLayer;
mDropPickupCommand.action = [this, &textures] (SceneNode& node, sf::Time)
{
createPickup(node, textures);
};
}
示例2: Entity
Aircraft::Aircraft(Type type, const TextureHolder& textures, const FontHolder& fonts)
: Entity(Table[type].hitpoints)
, mType(type)
, mFireCommand()
, mMissileCommand()
, mFireCountdown(sf::Time::Zero)
, mIsFiring(false)
, mIsLaunchingMissile(false)
, mShowExplosion(true)
, mSpawnedPickup(false)
, mSprite(textures.get(Table[type].texture), Table[type].textureRect)
, mExplosion(textures.get(Textures::Explosion))
, mFireRateLevel(1)
, mSpreadLevel(1)
, mMissileAmmo(2)
, mDropPickupCommand()
, mTravelledDistance(0.f)
, mDirectionIndex(0)
, mMissileDisplay(nullptr)
{
mExplosion.setFrameSize(sf::Vector2i(256, 256));
mExplosion.setNumFrames(16);
mExplosion.setDuration(sf::seconds(1));
centerOrigin(mSprite);
centerOrigin(mExplosion);
mFireCommand.category = Category::SceneAirLayer;
mFireCommand.action = [this, &textures] (SceneNode& node, sf::Time)
{
createBullets(node, textures);
};
mMissileCommand.category = Category::SceneAirLayer;
mMissileCommand.action = [this, &textures] (SceneNode& node, sf::Time)
{
createProjectile(node, Projectile::Missile, 0.f, 0.5f, textures);
};
mDropPickupCommand.category = Category::SceneAirLayer;
mDropPickupCommand.action = [this, &textures] (SceneNode& node, sf::Time)
{
createPickup(node, textures);
};
std::unique_ptr<TextNode> healthDisplay(new TextNode(fonts, ""));
mHealthDisplay = healthDisplay.get();
attachChild(std::move(healthDisplay));
if (getCategory() == Category::PlayerAircraft)
{
std::unique_ptr<TextNode> missileDisplay(new TextNode(fonts, ""));
missileDisplay->setPosition(0, 70);
mMissileDisplay = missileDisplay.get();
attachChild(std::move(missileDisplay));
}
updateTexts();
}
示例3:
PickupNode::PickupNode(const TextureHolder& textures)
:spread_sprite(textures.get(Textures::FireSpread), Table[Pickup::FireSpread].texture_rect)
,rate_sprite(textures.get(Textures::FireRate), Table[Pickup::FireRate].texture_rect)
{
spread_sprite.setOrigin(spread_sprite.getGlobalBounds().width / 2.f, spread_sprite.getGlobalBounds().width / 2.f);
rate_sprite.setOrigin(rate_sprite.getGlobalBounds().width / 2.f, rate_sprite.getGlobalBounds().width / 2.f);
rate_sprite.setPosition(spread_sprite.getPosition().x + 20.f, spread_sprite.getPosition().y);
spread_sprite.setScale(0.5f, 0.5);
rate_sprite.setScale(0.5f, 0.5);
}
示例4: mWindow
//The constructor for the game class.
Game::Game()
: mWindow(sf::VideoMode(1366, 768), "Top Down Shooter")
, mTexture()
, mPlayer()
{
TextureHolder textures;
textures.load(Textures::Airplane, "res/sprite.png");
mPlayer.setTexture(textures.get(Textures::Airplane));
mPlayer.setPosition(100, 100);
}
示例5: mCallback
Button::Button(const FontHolder& fonts, const TextureHolder& textures)
: mCallback(),
mNormalTexture(textures.get(Textures::ButtonNormal)),
mSelectedTexture(textures.get(Textures::ButtonSelected)),
mPressedTexture(textures.get(Textures::ButtonPressed)),
mSprite(),
mText("", fonts.get(Fonts::Main), 16),
mIsToggle(false) {
mSprite.setTexture(mNormalTexture);
centerOrigin(mSprite);
mText.setPosition(0, 0);
}
示例6: mCallback
Button::Button(const FontHolder& fonts, const TextureHolder& textures)
: mCallback()
, mNormalTexture(textures.get(Textures::ButtonNormal))
, mSelectedTexture(textures.get(Textures::ButtonSelected))
, mPressedTexture(textures.get(Textures::ButtonPressed))
, mSprite()
, mText("", fonts.get(Fonts::Main), 16)
, mIsToggle(false)
{
mSprite.setTexture(mNormalTexture);
sf::FloatRect bounds = mSprite.getLocalBounds();
mText.setPosition(bounds.width / 2.f, bounds.height / 2.f);
}
示例7:
Aircraft::Aircraft(Type type, const TextureHolder& textures)
: m_Type(type)
, m_Sprite(textures.get(toTextureID(type)))
{
sf::FloatRect bounds = m_Sprite.getLocalBounds();
m_Sprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
}
示例8: Entity
Projectile::Projectile(Type type, const TextureHolder& textures)
: Entity(1) //1 HP - so it's not detected as destroyed and not drawn
, type(type)
, sprite(textures.get(Table[type].texture))
{
centerOrigin(sprite);
}
示例9: Entity
Pickup::Pickup(Type type, const TextureHolder& textures)
: Entity(1)
, mType(type)
, mSprite(textures.get(Table[type].texture), Table[type].textureRect)
{
centerOrigin(mSprite);
}
示例10: mType
Person::Person(Type type, const TextureHolder& textures)
: mType(type)
, mSprite(textures.get(toTextureID(type)))
{
sf::FloatRect bounds = mSprite.getLocalBounds();
mSprite.setOrigin(bounds.width / 2.f, bounds.height / 2.f);
}
示例11: Entity
Asteroid::Asteroid(const TextureHolder& textures, b2World& world):
Entity(createBody(world))
{
AsteroidGenerator::makeRandomAsteroid(*this);
m_shape.setTexture(&textures.get(Textures::Asteroid));
int pointsCount = m_shape.getPointCount();
b2Vec2 vertices[pointsCount];
int j = pointsCount - 1;
for(int i = 0; i < pointsCount; ++i) // CCW
{
vertices[j].Set(m_shape.getPoint(i).x / SCALE, m_shape.getPoint(i).y / SCALE);
j--;
}
b2FixtureDef AsteroidFixtureDef;
b2PolygonShape AsteroidShape;
AsteroidShape.Set(vertices, pointsCount);
AsteroidFixtureDef.shape = &AsteroidShape;
AsteroidFixtureDef.density = 1.0f;
AsteroidFixtureDef.userData = this;
m_body->CreateFixture(&AsteroidFixtureDef);
m_shape.setOrigin(m_body->GetWorldCenter().x, m_body->GetWorldCenter().y);
}
示例12: Entity
Aircraft::Aircraft(Type type, const TextureHolder& textures, const FontHolder& fonts)
: Entity(Table[type].hitpoints)
, mType(type), mSprite(textures.get(Table[mType].texture), Table[mType].textRect),mHealthDisplay(nullptr)
, mTravelledDistance(0.f), mDirectionIndex(0), mIsFiring(false), mFireCountdown(sf::Time::Zero)
, mFireRateLevel(1), mFireCommand(), mSpreadLevel(1), mIsMarkedForRemoval(false)
, mMissileCommand(), mIsLaunchMissile(false), mMissileAmmo(2), mDropPickupCommand()
{
if (!isAllied())
mFireRateLevel = 0;
centerOrigin(mSprite);
std::unique_ptr<TextNode> healthDisplay(new TextNode(fonts, ""));
mHealthDisplay = healthDisplay.get();
attachChild(std::move(healthDisplay));
mFireCommand.category = Category::Scene;
mFireCommand.action = [this, &textures](SceneNode& node, sf::Time)
{
createBullet(node, textures);
};
mMissileCommand.category = Category::Scene;
mMissileCommand.action = [this, &textures] (SceneNode& node, sf::Time)
{
createProjectile(node, Projectile::Missile, 0.f, 0.5f, textures);
};
mDropPickupCommand.category = Category::Scene;
mDropPickupCommand.action = [this, &textures] (SceneNode& node, sf::Time)
{
createPickup(node, textures);
};
}
示例13: SceneNode
HelpNode::HelpNode(TextureHolder &textures) :
SceneNode(Category::None),
mFakePosition(152.f, -2.f)
{
mSprite.setTexture(textures.get(Textures::Help));
mSprite.setPosition(150.f, 55.f);
}
示例14: show
DeleteItem::DeleteItem(TextureHolder & textureHolder) : show(false){
sprite.setTexture(*textureHolder.getTexture(Textures::DeleteItem));
font.loadFromFile("resources/fonts/00TT.TTF");
setPosition(1280/2 - sprite.getTextureRect().width/2, 32);
deleteButton = sf::Rect<int>(getPosition().x + 57, getPosition().y + 61, 67, 25);
cancelButton = sf::Rect<int>(getPosition().x + 126, getPosition().y + 61, 67, 25);
}
示例15: mParticles
ParticleNode::ParticleNode(Particle::Type type, const TextureHolder& textures)
: mParticles()
, mTexture(textures.get(Textures::Particle))
, mType(type)
, mVertexArray(sf::Quads)
, mNeedsVertexUpdate(true)
{
}