16
No one?
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
bool MouseOver(sf::String &String)//overload with sf::String
{
if ( MouseX > String.GetRect().Left && MouseX < String.GetRect().Right)
{
if ( MouseY > String.GetRect().Top && MouseY < String.GetRect().Bottom)
return true;
}
else
return false;
}
bool IsInSight(const sf::Drawable &Drawable, sf::View &View)
{
int X = Drawable.GetPosition().x;
int Y = Drawable.GetPosition().y;
int Width = Drawable.GetScale().x;
int Height = Drawable.GetScale().y;
sf::FloatRect Rect(X, Y, X+Width, Y+Height);
sf::FloatRect ViewRect = View.GetRect();
//check if the sprite is in the view
if(ViewRect.Intersects(Rect))
window.Draw(Drawable);
}
bool DynamicWindow::IsInSight(const sf::Drawable &Drawable)
{
int X = Drawable.GetPosition().x;
int Y = Drawable.GetPosition().y;
if(X < 0 || X >= m_Width || Y < 0 || Y >= m_Height)//check if the Drawable can be seen
return false;
else
return true;
}
while(App.IsOpened())
{
//GetTheInput...
Sprite.SetPosition(MouseX,MouseY);
App.Clear();
App.Draw(Sprite);
App.Display();
}
bool MouseOver(sf::Sprite &Sprite)//returns true if the mouse is over given sf::Sprite
{
float XPos = Sprite.GetPosition().x;//the x position
float YPos = Sprite.GetPosition().y;//the y position
float XSize = Sprite.GetSize().x;//the width
float YSize = Sprite.GetSize().y;//the height
if(MouseX >= XPos && MouseX <= XPos+XSize && MouseY >= YPos && MouseY <= YPos+YSize)
return true;
else
return false;
}