If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
danielmccarthy
Posts: 51 Joined: Fri May 30, 2014 12:55 am
Post
by danielmccarthy » Sun Aug 10, 2014 8:47 pm
Checking for a button press is easy enough but how can I do it for an image? What is the event type?
I looked through irrlicht header files and their doesn't appear to be an event type for an image click? Is their another way around this ?
Code: Select all
int invItemX = 0;
int invItemY = 0;
IGUIImage* invItem = guienv->addImage(driver->getTexture("./media/Graphics/Items/coins.png"), core::position2d<s32>(invItemX, invItemY), true, 0, 907, L"Coins");
invItem->setName("inventory_item");
Thanks
CuteAlien
Admin
Posts: 9734 Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:
Post
by CuteAlien » Sun Aug 10, 2014 9:09 pm
You can catch mouse-click events (see example 19) and then go through the IGUIEnvironment::getRootGUIElement()->getElementFromPoint and compare the result to your image.
danielmccarthy
Posts: 51 Joined: Fri May 30, 2014 12:55 am
Post
by danielmccarthy » Sun Aug 10, 2014 11:28 pm
Thanks for your reply
My solution is a IGUIButton with its border removed
Code: Select all
int invItemX = 0;
int invItemY = 0;
int invItemWidth = 40;
int invItemHeight = 40;
IGUIButton* invItem = guienv->addButton(rect<s32>(invItemX, invItemY, invItemX + invItemWidth, invItemY + invItemHeight), 0, 907, L"", L"Coins");
invItem->setName("inventory_item");
invItem->setImage(driver->getTexture("./media/Graphics/Items/coins.png"));
invItem->setUseAlphaChannel(true);
invItem->setDrawBorder(false);
IGUIStaticText* itemStackTxt = guienv->addStaticText(L"300", core::rect<s32>(0, 0, 50, 20), false, false, invItem, -1);
CuteAlien
Admin
Posts: 9734 Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:
Post
by CuteAlien » Mon Aug 11, 2014 12:28 am
That certainly also works :-)