本文整理汇总了C++中sf::Sound::stop方法的典型用法代码示例。如果您正苦于以下问题:C++ Sound::stop方法的具体用法?C++ Sound::stop怎么用?C++ Sound::stop使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sf::Sound
的用法示例。
在下文中一共展示了Sound::stop方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: logic
void logic() {
sf::Time newTime = mainClock.getElapsedTime();
sf::Time diff = newTime - prevTime;
prevTime = newTime;
float difff = diff.asMicroseconds() / 1000000.f;
player.slowTime -= difff;
if (player.slowTime > 1) difff /= player.slowTime;
player.feather -= difff;
if (player.feather < 0.0f && player.hasFeather) {
sf::Text txt("Lavawalk expired", renderer.getFont());
txt.setColor(sf::Color(255, 255, 0, 255));
txt.setCharacterSize(36);
renderer.addStatusText(txt);
player.hasFeather = false;
alertSound.play();
}
float difff2 = (difff + diff.asMicroseconds() / 1000000.f) / 2;
int z1 = std::floor(player.z + 1.3);
int z2 = std::floor(player.z + 0.9);
int x1 = std::floor(player.x + 2.1);
int x2 = std::floor(player.x + 1.9);
if (rockZ > tunnel.getLength() - 1 && tunnel.hasBrickWall()) {
//destroy bricks
for (float i = -2; i <= 2; i += 0.1f) {
for (float j = -2; j <= 2; j += 0.1f) {
renderer.addParticles(1, sf::Color(108, 7, 7), sf::Vector3f(i, j, tunnel.getLength()));
}
}
tunnel.breakWall();
}
if (player.fallen) {
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Return)) {
resetGame();
}
feetSound.stop();
player.zVel -= difff * 10;
if (player.zVel < 0) player.zVel = 0;
if (rockZ > player.z) {
static float parts = 0;
parts += difff * 20;
while(parts > 0) {
renderer.addParticles(1, sf::Color(100, 50, 10), sf::Vector3f(rand() / (float)RAND_MAX * 2 - 1, 2, rockZ + 2));
parts--;
}
}
} else if (rockZ > player.z) {
player.fallen = true;
fallingSound.play();
musicSound.pause();
renderer.addParticles(10, sf::Color(255, 0, 0), sf::Vector3f(player.x, 2, player.z));
player.y = -100;
} else if (!(player.feather > 0) && (player.y < 0.01 && (tunnel.get(z1, x1) == 1 && tunnel.get(z2, x1) == 1 && tunnel.get(z1, x2) == 1 && tunnel.get(z2, x2) == 1))) {
player.fallen = true;
fallingSound.play();
musicSound.pause();
renderer.addParticles(10, sf::Color(255, 127, 0), sf::Vector3f(player.x, 3, player.z));
/*
sf::Text txt("Fail!", renderer.getFont());
txt.setColor(sf::Color(255, 0, 0, 255));
txt.setCharacterSize(36);
renderer.addStatusText(txt);
*/
} else {
if (!player.fallen && player.y < 0.3 && (tunnel.get(z1, x1) > 1 && tunnel.get(z2, x1) > 1 && tunnel.get(z1, x2) > 1 && tunnel.get(z2, x2) > 1)) {
int rok = tunnel.get(z1, x1);
if (rok != 5) {
if (rok == 2)
player.zVel = 1.5;
else if (rok == 3)
player.zVel = 3.5f;
else if (rok == 4)
player.zVel = 0.0f;
bumpSound.play();
tunnel.set(z1, x1, 0);
renderer.addParticles(10, sf::Color(100, 100, 100), sf::Vector3f(player.x, 2, player.z));
}
} else if (!player.fallen && player.y > 0.3 && (tunnel.get(z1, x1 + 5) >= 1 && tunnel.get(z2, x1 + 5) >= 1 && tunnel.get(z1, x2 + 5) >= 1 && tunnel.get(z2, x2 + 5) >= 1)) {
int gem = tunnel.get(z1, x1 + 5);
if (gem <= 3) {
player.score += gem;
gemSound.play();
if (gem == 1) {
renderer.addParticles(5, sf::Color(200, 0, 0), sf::Vector3f(player.x, .5, player.z + 1));
sf::Text txt("Ruby: +1", renderer.getFont());
txt.setColor(sf::Color(255, 0, 0, 255));
txt.setCharacterSize(36);
renderer.addStatusText(txt);
} else if (gem == 2) {
renderer.addParticles(5, sf::Color(0, 255, 0), sf::Vector3f(player.x, .5, player.z + 1));
sf::Text txt("Emerald: +2", renderer.getFont());
txt.setColor(sf::Color(0, 255, 0, 255));
txt.setCharacterSize(36);
//.........这里部分代码省略.........