本文整理汇总了C++中sf::RectangleShape::setTextureRect方法的典型用法代码示例。如果您正苦于以下问题:C++ RectangleShape::setTextureRect方法的具体用法?C++ RectangleShape::setTextureRect怎么用?C++ RectangleShape::setTextureRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::RectangleShape
的用法示例。
在下文中一共展示了RectangleShape::setTextureRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintLighting
void cWindow::paintLighting()
{
float power;
int tex;
int lightsDisplayed = 0;
int priority = 0;
for (int a = 0; a < 2; a++)
{
priority = 0;
while (priority < LIMIT_PRIORITY_LIGHT && lightsDisplayed < game.unitCounter)
{
for (int i = 0; i < game.unitCounter; i++)
{
if (game.unit[i].light.priority == priority && game.unit[i].light.power > 0 && game.unit[i].light.texture != -1)
{
tex = game.unit[i].light.texture;
brushRect.setTexture(&visual.gameTex[tex].handle);
brushRect.setPosition(game.unit[i].pos);
brushRect.setFillColor(sf::Color(255, 255, 255, max(0.00f, min(255.00f, 300.00f - game.ambientLight))));
if (!settings.enableDynamicLight) {
brushRect.setTexture(&visual.gameTex[visual.addTexture("light_white.png")].handle);
brushRect.setFillColor(sf::Color(255, 255, 255, 50.00f));
}
brushRect.setTextureRect(sf::IntRect(0, 0, visual.gameTex[tex].handle.getSize().x, visual.gameTex[tex].handle.getSize().y));
power = game.unit[i].light.power;
if (game.unit[i].light.flickerMod != 0.00f) {
power += power * (game.unit[i].light.flickerMod * abs(game.unit[i].light.flickerCurTime / game.unit[i].light.flickerTime - 1.00f));
power += math.randf(-5.00f, 5.00f);
}
brushRect.setOrigin(sf::Vector2f(power, power));
brushRect.setSize(sf::Vector2f(power * 2.00f, power * 2.00f));
// Directional
brushRect.setRotation(0.00f);
if (game.unit[i].light.directional) {
brushRect.setRotation(-game.unit[i].facingAngle);
}
// Painting to two textures
if (settings.enableDynamicLight && a == 0) { window.texHandleLight.draw(brushRect, window.matrixHandle); }
else if (settings.enableDynamicLight && a == 1) { window.texHandleLightMult.draw(brushRect, window.matrixHandle); }
else { window.texHandle.draw(brushRect, window.matrixHandle); }
}
}
priority += 1;
}
if (!math.intToBool(settings.enableBetterLight)) { break; }
}
brushRect.setRotation(0.00f);
window.texHandleLight.display();
if (settings.enableBetterLight) { window.texHandleLightMult.display(); }
}