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


C++ SoundManager::createSounds方法代码示例

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


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

示例1: main

int main() {
	sf::RenderWindow window(sf::VideoMode(1920, 1080), "Corgi Movement Simulator");
	/*sf::CircleShape shape(100.f); 
	shape.setFillColor(sf::Color::Green);*/

	/*sf::Texture texture;
	texture.loadFromFile("Sprites/Scene10x10.png");
	texture.setSmooth(true);
	sf::Sprite* sprite = (new sf::Sprite(texture));*/
	//(*sprite).setColor(sf::Color(128, 128, 128));

	//testlvlManager

	sf::Texture shibe;
	if (!shibe.loadFromFile("Sprites/Units/shibe_spread.png"))
	{
		std::cout << "Failed to load player spritesheet!" << std::endl;
		return 1;
	}

	Animation shibe_idle;
	shibe_idle.setSpriteSheet(shibe);
	shibe_idle.addFrame(sf::IntRect(0, 0, 128, 128));
	shibe_idle.addFrame(sf::IntRect(128, 0, 128, 128));
	shibe_idle.addFrame(sf::IntRect(256, 0, 128, 128));
	shibe_idle.addFrame(sf::IntRect(384, 0, 128, 128));

	AnimatedSprite animatedShibe(sf::seconds(0.2), false, true);
	animatedShibe.setPosition(0,0);
	animatedShibe.play(shibe_idle);

	TextureManager texMng;
	texMng.getFiles();
	texMng.createTextures();

	lvlManager lvl;
	Block b = lvl.generateTiles(lvl.buildKey(&texMng), &texMng);
	lvl.genMap(b, 0, 15);
	for (int i = 0; i < 50; i++){
		Block b = lvl.generateTiles(lvl.buildKey(&texMng), &texMng);
		sf::Vector2<int> v = lvl.findNextSpot(b.x, b.y);
		if (v.x != -1)
			lvl.genMap(b, v.x, v.y);
	}

	SoundManager sM;
	sM.getFiles();
	sM.createSounds();

	Player p(&texMng, &(sM.soundTable.at("bark")), sf::Sprite());

	//Unit test_unit(10, 10, *sprite);
	//Tile test(sprite, &test_unit);
	sf::Sprite output;
	lvl.genDrawable(&output);
	UIManager uimanager;
	uimanager.setTerrain(output);
	//uimanager.setTerrain(lvl.genDrawable());
	int mousex=0, mousey=0;

	//lvl.testTileGen(&texMng, &window);

	//testTextureManager(&window);

	UnitManager uM(&lvl, &texMng, &p, &sM);
	uM.spawnUnit(doge, p.playerUnit->x + 1, p.playerUnit->y);
	uM.spawnUnit(turtle, p.playerUnit->x, p.playerUnit->y + 1);
	std::cout << p.playerUnit->x + 1 <<  p.playerUnit->y + 1 << std::endl;
	uM.gatherActions();

	sf::Clock frameClock;
	while (window.isOpen())
	{
		sf::Event event;
		while (window.pollEvent(event))
		{
			if (event.type == sf::Event::Closed || sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))
				window.close();
			if (event.type == sf::Event::MouseButtonPressed)
			{
				mousex = sf::Mouse::getPosition(window).x;
				mousey = sf::Mouse::getPosition(window).y;

			}
			if (sf::Mouse::isButtonPressed(sf::Mouse::Left) && event.type == sf::Event::MouseMoved)
			{
				uimanager.x += event.mouseMove.x-mousex;
				uimanager.y += event.mouseMove.y-mousey;
				mousex = event.mouseMove.x;
				mousey = event.mouseMove.y;
			}
			if (sf::Keyboard::isKeyPressed(sf::Keyboard::P)) 
			{
				uM.gatherActions();
			}
			if (event.type == sf::Event::MouseButtonReleased && event.mouseButton.button == sf::Mouse::Button::Right)
			{
				std::cout << "clicked at " << sf::Mouse::getPosition(window).x-uimanager.x << " " << sf::Mouse::getPosition(window).y-uimanager.y << std::endl;
				//std::cout << "is accessible: " << lvl.isAccessible(sf::Mouse::getPosition(window).x - uimanager.x, sf::Mouse::getPosition(window).y - uimanager.y) << std::endl;
				int xPos = sf::Mouse::getPosition(window).x - uimanager.x;
//.........这里部分代码省略.........
开发者ID:PhilWimmer,项目名称:MagicFunGame,代码行数:101,代码来源:Quelle.cpp


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