Click on an image

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.
Post Reply
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Click on an image

Post by sivagiri »

How could I click on an image, then when I do it it shows a message....?
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

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();


}
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.
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Post by sivagiri »

thanx :lol:
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Post by sivagiri »

I'm a bit tired: thats the prob and having cold.

One more question or two:


I would like the image on my button fit the button totally: How can I do that?

:)
sivagiri
Posts: 22
Joined: Sat Jun 10, 2006 4:31 pm

Post by sivagiri »

button1 = env->addButton(rect<s32>(120,160,270,350),0,200);
button1->setImage(driver->getTexture("mediam/pics/kep1.bmp"),core::rect< s32>(120,160,270,350));


I did this, and it fits the button, but looks kind of :oops: ....
RhavoX
Posts: 33
Joined: Tue Jul 04, 2006 7:27 pm

Post by RhavoX »

button1->setImage(driver->getTexture("mediam/pics/kep1.bmp"rect<s32>(120,160,270,350));

Code: Select all

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 :)
Teh Uber-Pwner xD
Post Reply