Click on an image
Click on an image
How could I click on an image, then when I do it it shows a message....?
Dude just read the ****** tutorials!!!!!!
I typed a special one just for u cause i was bored....but read the tutorial
IrrlichtDevice* device;
video::IVideoDriver* driver;
gui::IGUIEnvironment* gui;
IGUIButton button;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* env = device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (id == 200)
{
gui->addWindow(rect<s32>(10,10,90,90),false,L"HALLO");
return true;
}
break;
}
return false;
}
};
int main()
{
device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640,480), 16 , false, false, false, new MyEventReceiver());
driver = device->getVideoDriver();
gui = device->getGUIEnvironment() ;
button = gui->addButton(rect<s32>(50,50,100,100),0,200);
button->setImage(driver->getTexture("YOUR TEXTURE") ;
// draw everything
while(device->run() && driver)
{
driver->beginScene(true, true, video::SColor(255,0,0,255));
gui->drawAll();
driver->endScene();
}
// delete device
device->drop();
}
I typed a special one just for u cause i was bored....but read the tutorial
IrrlichtDevice* device;
video::IVideoDriver* driver;
gui::IGUIEnvironment* gui;
IGUIButton button;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(SEvent event)
{
if (event.EventType == EET_GUI_EVENT)
{
s32 id = event.GUIEvent.Caller->getID();
IGUIEnvironment* env = device->getGUIEnvironment();
switch(event.GUIEvent.EventType)
{
case EGET_BUTTON_CLICKED:
if (id == 200)
{
gui->addWindow(rect<s32>(10,10,90,90),false,L"HALLO");
return true;
}
break;
}
return false;
}
};
int main()
{
device = createDevice(video::EDT_OPENGL, core::dimension2d<s32>(640,480), 16 , false, false, false, new MyEventReceiver());
driver = device->getVideoDriver();
gui = device->getGUIEnvironment() ;
button = gui->addButton(rect<s32>(50,50,100,100),0,200);
button->setImage(driver->getTexture("YOUR TEXTURE") ;
// draw everything
while(device->run() && driver)
{
driver->beginScene(true, true, video::SColor(255,0,0,255));
gui->drawAll();
driver->endScene();
}
// delete device
device->drop();
}
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
button1->setImage(driver->getTexture("mediam/pics/kep1.bmp"rect<s32>(120,160,270,350));
This sets the position of an image IN your button, not in the program window..The fisrt two coordinates should be set to 0, the other two to the image's width and height.
But this part is not even necessary. If your image's width and height are powers of 2, then it will be displayed correctly and it will fit the button
Code: Select all
rect<s32>(120,160,270,350));
But this part is not even necessary. If your image's width and height are powers of 2, then it will be displayed correctly and it will fit the button
Teh Uber-Pwner xD