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


C++ RenderWindow::Draw方法代码示例

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


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

示例1: Draw

void Player::Draw(sf::RenderWindow& iWindow, sf::Color& iColor, float timeElapsed) const
{
	if(!mIsActive)
		return;

	sf::Shape cannon;
	sf::Color regularColor = iColor;
	
	if(mLife < 30 && ((int)timeElapsed%2))
	{
		iColor.a -= 130;
	}
	


	// create the cannon shape
	cannon.AddPoint(0, 0, iColor, sf::Color(255, 255, 255));
	cannon.AddPoint(20, 0, iColor,   sf::Color(255, 255, 255));
	cannon.AddPoint(20, 20, iColor, sf::Color(255, 255, 255));
	cannon.AddPoint(15, 20, iColor, sf::Color(255, 255, 255));
	cannon.AddPoint(15, 40, iColor, sf::Color(255, 255, 255));
	cannon.AddPoint(5, 40, iColor, sf::Color(255, 255, 255));
	cannon.AddPoint(5, 20, iColor, sf::Color(255, 255, 255));
	cannon.AddPoint(0, 20, iColor, sf::Color(255, 255, 255));


	// Define an outline width
	cannon.SetOutlineWidth(2);

	// Disable filling and enable the outline
	cannon.EnableFill(true);
	cannon.EnableOutline(true);

	cannon.SetColor(sf::Color(255, 255, 255));

	/*cannon.Move(mPosition.X(), mPosition.Y());
	cannon.SetCenter(10,0);
	cannon.Rotate(mCannonRotation);*/

	// move and rotate the shape for each player
	cannon.Move(mPosition.X(), mPosition.Y());
	cannon.SetCenter(10,0);

	//switch(mID)
	//{

	//case 0:
	//	cannon.Rotate(mCannonRotation);
	//	break;
	//case 1:
	//	cannon.Rotate(mCannonRotation+90.0f);
	//	break;
	//case 2:
	//	cannon.Rotate(mCannonRotation+180.0f);
	//	break;
	//case 3:
	//	cannon.Rotate(mCannonRotation-90.0f);
	//	break;
	//}

	cannon.Rotate(mCannonRotation);


	// Draw the cannon
	iWindow.Draw(cannon);


	// draw projectiles
	for(int i=0; i<mProjectiles.size(); i++)
	{
		mProjectiles.at(i)->Draw(iWindow,regularColor);
	}


}
开发者ID:JacopoV,项目名称:MoonCraft,代码行数:75,代码来源:Player.cpp

示例2: draw

void WidgetBase::draw(sf::RenderWindow &window) const {
    window.Draw(_sprite);
}
开发者ID:phaazon,项目名称:iutbx1-ds,代码行数:3,代码来源:Widget.cpp

示例3: afficher

//*Methodes
void Carte::afficher(sf::RenderWindow& App,std::string txt){
    if (txt.compare("inf") == 0)
        App.Draw(Iinf);
    else
        App.Draw(Isup);
}
开发者ID:AntipodGames,项目名称:Fly,代码行数:7,代码来源:carte.cpp

示例4: Draw

void Animation::Draw(sf::RenderWindow &Window)
{
	Window.Draw(spriteImage);
}
开发者ID:alienwizard,项目名称:VisualStudio,代码行数:4,代码来源:Animation.cpp

示例5: drawInventory

void Player::drawInventory(sf::RenderWindow& rw) const
{
	static bool firstRun = true;
	static sf::Image tlo;
	static sf::Font font;
	if(firstRun) 
	{
		tlo.LoadFromFile("Images/inv.png");
		firstRun = false;
		font.LoadFromFile("silesiana.otf", 50,  L"A�BC�DE�FGHIJKL�MN�O�PRS�TUWYZ��a�bc�de�fghijkl�mn�o�prs�tuwyz��[email protected]#$%^&*()_-[]\\;',./{}:\"<>?=-+ ");
	}

	sf::Sprite tloH(tlo);
	rw.Draw(tloH);
	
	std::stringstream ss;
	ss<<"Masz " << coins << " $";
	sf::String t(ss.str(), font, 30.f);
	t.SetColor(sf::Color(20, 18, 160));
	t.SetPosition(600.f, 30.f);
	rw.Draw(t);

	float posy = 30.0;
	int i = 0;
	for(std::vector<Item>::const_iterator it = inventory.begin(); it != inventory.end(); it++)
	{
		std::wstring name = it->getName();
		if(i == weapon)
		{
			name += L" (uzbrojny - bro�)";
		}
		if(i == armor)
		{
			name += L" (uzbrojny - zbroja)";
		}
		sf::String t(name, font, 30.f);
		t.SetColor(sf::Color(20, 18, 160));
		if(selectedItem == i)
			t.SetColor(sf::Color(200, 18, 160));
		t.SetPosition(20.f, posy);
		rw.Draw(t);
		posy += 30.0;
		i++;
	}
	if(0 <= selectedItem && selectedItem < inventory.size())
	{
		TextArea desc(inventory[selectedItem].getDesc(), 400, font);
		desc.SetPosition(300, 50);
		rw.Draw(desc);
		Item::Type type = inventory[selectedItem].getProperty();
		if(type == 0)
		{
			TextArea desc1(L"Bron - Atak + " +inventory[selectedItem].getBoost(), 400,font);
			desc1.SetPosition(350,250);
			rw.Draw(desc1);
		}
		else if(type == 1)
		{
			TextArea desc1(L"Zbroja - Obrona + " +inventory[selectedItem].getBoost(), 400,font);
			desc1.SetPosition(350,250);
			rw.Draw(desc1);
		}
		else if(type == 2)
		{
			TextArea desc1(L"Helm - Obrona + " +inventory[selectedItem].getBoost(), 400,font);
			desc1.SetPosition(350,250);
			rw.Draw(desc1);
		}
		else if(type == 3)
		{
			TextArea desc1(L"Mikstura", 460,font);
			desc1.SetPosition(350,250);
			rw.Draw(desc1);
		}

		
	}
}
开发者ID:khaiduk,项目名称:rogalik,代码行数:78,代码来源:Player.cpp

示例6: Draw

void TankSpawn::Draw(sf::RenderWindow& wnd){
	wnd.Draw(mSprite);
}
开发者ID:skwee357,项目名称:TankSmasher,代码行数:3,代码来源:TankSpawn.cpp

示例7: Draw

void IGui::Draw(sf::RenderWindow& window)
{
    window.Draw(sprite);
}
开发者ID:DanLB,项目名称:Maze,代码行数:4,代码来源:IGui.cpp

示例8: renderForeground

void Map::renderForeground(sf::RenderWindow& window) const
{
	window.Draw(*mForeground);
}
开发者ID:TokyoBirdy,项目名称:MasterOfSorcery,代码行数:4,代码来源:Map.cpp

示例9: Draw

	void Node::Draw(sf::RenderWindow &renderWindow){
		if (_isLoaded){
			renderWindow.Draw(_sprite);
		}
	}
开发者ID:dragoon20,项目名称:codeur-de-chevalier-tower-defense,代码行数:5,代码来源:Node.cpp

示例10: Draw

void Frame::Draw(sf::RenderWindow& W){
    if(sprite)
        W.Draw(*sprite);
}
开发者ID:Beulard,项目名称:beul,代码行数:4,代码来源:Frame.cpp

示例11: renderBackground

void Map::renderBackground(sf::RenderWindow& window) const
{
	window.Draw(*mBackground);
}
开发者ID:TokyoBirdy,项目名称:MasterOfSorcery,代码行数:4,代码来源:Map.cpp

示例12: run


//.........这里部分代码省略.........
                    if(monEvent.MouseButton.X > SpriteFlecheGauche5.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheGauche5.GetPosition().x + TAILLEFLECHE)
                    {
                        l = l - TAILLEIMAGEMANCHES;
                        if(l < 0)
                        {
                            l = TAILLETILEMANCHES - TAILLEIMAGEMANCHES;
                        }
                        SpriteNombreManches.SetSubRect(sf::IntRect(l, 0, l + TAILLEIMAGEMANCHES, TAILLEIMAGEMANCHES));
                    }

                    //Cas ou on clique sur la fleche suivant pour le choix du nombre de manches gagnantes
                    if(monEvent.MouseButton.X > SpriteFlecheDroite4.GetPosition().x && monEvent.MouseButton.X < SpriteFlecheDroite4.GetPosition().x + TAILLEFLECHE)
                    {
                        l = l + TAILLEIMAGEMANCHES;
                        if(l >= TAILLETILEMANCHES)
                        {
                            l = 0;
                        }
                        SpriteNombreManches.SetSubRect(sf::IntRect(l, 0, l + TAILLEIMAGEMANCHES, TAILLEIMAGEMANCHES));
                    }
                }

                //Cas ou on clique sur Commencer
                if(monEvent.MouseButton.X > 530 && monEvent.MouseButton.X < 710)
                {
                    if(monEvent.MouseButton.Y > 660 && monEvent.MouseButton.Y < 710)
                        {
                            //Switch sur i pour savoir quel perso a choisi le joueur 1
                            switch(i)
                            {
                                case 0*TAILLEIMAGEPERSO:
                                joueur1 = "zelda";
                                break;

                                case 1*TAILLEIMAGEPERSO:
                                joueur1 = "mario";
                                break;

                            }

                            //Switch sur j pour savoir quel perso a choisi le joueur 2
                            switch(j)
                            {
                                case 0*TAILLEIMAGEPERSO:
                                joueur2 = "zelda";
                                break;

                                case 1*TAILLEIMAGEPERSO:
                                joueur2 = "mario";
                                break;

                            }

                            //Switch sur k pour savoir quel map ont choisi les joueurs
                            switch(k)
                            {
                                case 0*TAILLEIMAGEMAP:
                                map = "zelda";
                                break;

                                case 1*TAILLEIMAGEMAP:
                                map = "mario";
                                break;

                            }

                            //On initialise le nombre de parties gagnantes
							perso1.setNombreDeManchesGagnantes((int)(l / TAILLEIMAGEMANCHES) + 1);
							perso2.setNombreDeManchesGagnantes((int)(l / TAILLEIMAGEMANCHES) + 1);

							perso1.setThemePersonnage(joueur1);
                            perso2.setThemePersonnage(joueur2);
                            affichage.setThemeCarte(map);
                            return (ECRAN_JEU); // On rentre dans l'écran du jeu
                        }
                }
            }
		}

		fenetre.Clear();
		fenetre.Draw(SpriteMulti);

		fenetre.Draw(SpriteFlecheDroite1);
		fenetre.Draw(SpriteFlecheDroite2);
		fenetre.Draw(SpriteFlecheDroite3);
		fenetre.Draw(SpriteFlecheDroite4);
		fenetre.Draw(SpriteFlecheGauche1);
		fenetre.Draw(SpriteFlecheGauche2);
		fenetre.Draw(SpriteFlecheGauche3);
		fenetre.Draw(SpriteFlecheGauche4);
		fenetre.Draw(SpriteFlecheGauche5);

		fenetre.Draw(SpritePerso1);
		fenetre.Draw(SpritePerso2);
		fenetre.Draw(SpriteMap);
		fenetre.Draw(SpriteNombreManches);
		fenetre.Display();
	}
	return (ECRAN_QUITTER);
}
开发者ID:colbat,项目名称:supersmashbomber,代码行数:101,代码来源:EcranMenuMulti.cpp

示例13: Draw

void Block::Draw(sf::RenderWindow& Window)const{
    Block::Sprite.SetPosition(Location);
    Window.Draw(Block::Sprite);
}
开发者ID:Zeatherann,项目名称:ToTheExit,代码行数:4,代码来源:Block.cpp

示例14: draw

void const MoveOrder::draw(sf::RenderWindow &App)
{
	destination_circle = sf::Shape::Circle(xpos, ypos, 2, sf::Color(0,0,0,0), 2, sf::Color::White);
	App.Draw(destination_circle);
}
开发者ID:stewartmatheson,项目名称:Leytonstone,代码行数:5,代码来源:MoveOrder.cpp

示例15: draw

 //draws the chess piece
 void Knight::draw(sf::RenderWindow& canvas)const{
     canvas.Draw(m_sprite);
 }
开发者ID:dchhetri,项目名称:SFML-Chess,代码行数:4,代码来源:Knight.cpp


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