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


C++ FloatRect::contains方法代码示例

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


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

示例1: onClickContext

/*-------------------------------------------------------------------------------------------------------------------- 
-- FUNCTION: onClickContext
--
-- DATE: 2013/02/28
--
-- REVISIONS: (Date and Description)
--
-- DESIGNER: Luke Tao
--
-- PROGRAMMER: Luke Tao
--
-- INTERFACE: int InputManager::onClickContext(sf::Event mouseEvent, sf::FloatRect menuContext, 
--						sf::FloatRect buildContext, sf::FloatRect playContext)
--					       
--					       sf::Event mouseEvent - the mouse event
--					       sf::FloatRect menuContext - the menu context
--					       sf::FloatRect buildContext - the builder context
--					       sf::Float Rect playContext - the player context
--
-- RETURNS: Context defined values.
--
-- NOTES: This function handles the events of the mouse clicks. It will print out the coordinates of where the
--	  mouse click happens and determines if it is within one of the context buttons. If the mouse click is within
--        the buttons, it will set the current context value and return that value.
----------------------------------------------------------------------------------------------------------------------*/
int InputManager::onClickContext(sf::Event mouseEvent, sf::FloatRect menuContext, sf::FloatRect buildContext, sf::FloatRect playContext)
{
	int x = mouseEvent.mouseButton.x;
	int y = mouseEvent.mouseButton.y;

	std::cout << "x :" << x << " y: " << y << std::endl;
	if(menuContext.contains(x, y))
	{
		//call menu function
		std::cout << "Context changed to menu" << std::endl;
		setCurrentContext(MENU_CONTEXT);
		return MENU_CONTEXT;
	}
	else if(buildContext.contains(x, y))
	{
		//call builder function
		std::cout << "Context changed to builder" << std::endl;
		setCurrentContext(BUILDER_CONTEXT);
		return BUILDER_CONTEXT;
	}	
	else if(playContext.contains(x, y))
	{
		//call player function
		std::cout << "Context changed to player" << std::endl;
		setCurrentContext(PLAYER_CONTEXT);
		return PLAYER_CONTEXT;
	}
	return getCurrentContext();
}
开发者ID:JohnPayment,项目名称:Project,代码行数:54,代码来源:InputManager.cpp

示例2: triIntersectRect

 bool triIntersectRect(sf::Vector2f t1, sf::Vector2f t2, sf::Vector2f t3, sf::FloatRect rect) {
   //the triangle is made by t1, t2 & t2.
   //return true if the triangle & the rectangle intersect
   if ( rect.contains(t1) || rect.contains(t2) || rect.contains(t3) )
     return true;
   if (lineSegInTriangle(t1,t2,t3,sf::Vector2f(rect.left, rect.top), sf::Vector2f(rect.left+rect.width, rect.top))
     || lineSegInTriangle(t1,t2,t3,sf::Vector2f(rect.left+rect.width, rect.top), sf::Vector2f(rect.left+rect.width, rect.top+rect.height))
     || lineSegInTriangle(t1,t2,t3,sf::Vector2f(rect.left+rect.width, rect.top+rect.height), sf::Vector2f(rect.left, rect.top+rect.height))
     || lineSegInTriangle(t1,t2,t3,sf::Vector2f(rect.left, rect.top+rect.height), sf::Vector2f(rect.left, rect.top) ) )
       return true;
   return false;
 }
开发者ID:bugubugu123,项目名称:Game_Design_Group_4_Project,代码行数:12,代码来源:collisionDetection.cpp

示例3: Cull

void LayerSet::Cull(const sf::FloatRect& bounds)
{
	if(	bounds.contains(m_boundingBox.left, m_boundingBox.top) ||
		bounds.contains(m_boundingBox.width, m_boundingBox.height) ||
		m_boundingBox.contains(bounds.left, bounds.top) ||
		m_boundingBox.contains(bounds.left + bounds.width, bounds.top + bounds.height))
	{
		m_visible = true;
	}
	else
	{
		m_visible = false;
	}
}
开发者ID:DioMuller,项目名称:quest-for-the-crown-j,代码行数:14,代码来源:MapLayer.cpp

示例4:

//Check collision between a single rectangle and a point
int Level2::checkCollision(const sf::FloatRect &boundingBox, sf::Vector2f &point)
{
	if (boundingBox.contains(point))
	{
		return 1;
	}
	return 0;
}
开发者ID:Arqu3,项目名称:Spelprojekt-1,代码行数:9,代码来源:Level2.cpp

示例5:

list<Unit*> Joueur::getUnitsInRect(sf::FloatRect rectangleSelection)
{
  list<Unit*> liste;
  list<Unit*>::iterator it;
  for(it = units.begin(); it != units.end(); it++)
    if(rectangleSelection.contains((*it)->getPosition().x + (*it)->getSocleCenter().x, (*it)->getPosition().y + (*it)->getSocleCenter().y)) 
      liste.push_back(*it);
  return liste;
}
开发者ID:matthieu637,项目名称:risk,代码行数:9,代码来源:Joueur.cpp

示例6: AABBCollision

bool AABBCollision(const sf::FloatRect& box, float x, float y)
{
    return box.contains(x, y);
}
开发者ID:TheFakeCake,项目名称:CakeWork,代码行数:4,代码来源:utils.cpp

示例7: onMouseOver

bool Game::onMouseOver(sf::FloatRect rect)
{
    return rect.contains(State->mouse.getPosition().x,State->mouse.getPosition().y);
}
开发者ID:cristo512,项目名称:Games,代码行数:4,代码来源:Game.cpp


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