Hi!
I'm drawing a wide char string(irr::core::stringw) using
IGUIFont::draw(). I'm drawing a particular string while mouse hovering an image(by doing hit test). I'm drawing a different string while the mouse is away from the image. My normal string(Mouse away string) is overlapping with my mouse over string. How to clear the mouse over string?
Clearing a Stringw
IGUIFont::draw() draws directly to viewport, so the drawn string will be cleared only when you beginScene(...with clearing color buffer...) again.
All should be fine if you do it in next way:
so you redraw necessary text every frame.
All should be fine if you do it in next way:
Code: Select all
driver->beginScene();
....
if (mouseHoversTheImage)
s = "OVER";
else
s = "AWAY";
font->draw(s);
....
driver->endScene();
Hi!
I'm using this code inside the gameloop.
"testStr" is a private variable in my class and assigned value in the function GetString(int). If use the above code as u suggested mouse hover string is not drawn(only current level string is always drawn). If I draw the string in both if and else sections(i.e placing last line of code in both the sections), Mouse hover and current level strings are overlapping.
How to resolve this problem?
I'm using this code inside the gameloop.
Code: Select all
for(int i = 0; i < levels; i++)
{
MousePtr = device->getCursorControl()->getPosition();
if(circleImage[i]->getRelativePosition().isPointInside(MousePtr))
{
GetString(i);
}
else
GetString(curLevel);
}
pManager->getFont()->draw(testStr.c_str(),recti(20,20,100,60),RED,true);
How to resolve this problem?
Would be interested in seeing you GetString function, i think something strange may be happening in there. But that wouldn't explain the overlap.
I don't think this has anything to do with Irrlicht.
Here is one solution.
I don't think this has anything to do with Irrlicht.
Here is one solution.
Code: Select all
bool bDrawHoverString = false;
MousePtr = device->getCursorControl()->getPosition();
for(int i = 0; i < levels; i++)
{
if(circleImage[i]->getRelativePosition().isPointInside(MousePtr))
{
bDrawHoverString = true;
break;
}
}
if( bDrawHoverString )
{
// set the string here
testStr = "We are hovering";
}
else
{
// set the string here
testStr = "We are NOT hovering";
}
pManager->getFont()->draw(testStr.c_str(),recti(20,20,100,60),RED,true);