本文整理汇总了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();
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例6: AABBCollision
bool AABBCollision(const sf::FloatRect& box, float x, float y)
{
return box.contains(x, y);
}
示例7: onMouseOver
bool Game::onMouseOver(sf::FloatRect rect)
{
return rect.contains(State->mouse.getPosition().x,State->mouse.getPosition().y);
}