IGUIButton does not work !

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
aktlakfh1777
Posts: 17
Joined: Sun Dec 21, 2008 1:40 am

IGUIButton does not work !

Post by aktlakfh1777 »

what can i do ?

Code: Select all

class gameFrames:public IEventReceiver
{
private:
	DataBank *db;
	IVideoDriver* _driver;
	ISceneManager* _smgr;
	IGUIEnvironment* _guienv;
	IrrlichtDevice* _device;
	IGUISkin* skin;
	IGUIFont* font;
	framesWork *fw;
	GuiManagement *guiman;
	IEventReceiver *_eru_;
	int nfGameLevel;
	int nowFrame;
	int nLoginWork;
	bool loadedComplete;
public:
	graphic_ARGBUnit *gfARGB;
	void valueInit()
	{
		this->fw=new framesWork();
		this->nowFrame=0;
		this->loadedComplete=false;
		this->db=new DataBank();
		this->nfGameLevel=0;
		this->nLoginWork=0;
		this->skin = _guienv->getSkin();
		this->font = _guienv->getFont("datas/font.bmp");
		if (this->font)
			this->skin->setFont(this->font);
		this->skin->setFont(_guienv->getBuiltInFont(), EGDF_TOOLTIP);
		this->guiman=new GuiManagement(_guienv);
	}
	gameFrames(IVideoDriver *_drv,ISceneManager *_smr,IGUIEnvironment *_gui,IrrlichtDevice *_irrDev)
	{
		this->_driver=_drv;
		this->_smgr=_smr;
		this->_device=_irrDev;
		this->_guienv=_device->getGUIEnvironment();
		this->valueInit();
	}
	gameFrames(IVideoDriver *_drv,ISceneManager *_smr,IGUIEnvironment *_gui,IrrlichtDevice *_irrDev,graphic_ARGBUnit *argbunit)
	{
		this->_driver=_drv;
		this->_smgr=_smr;
		this->_guienv=_gui;
		this->_device=_irrDev;
		this->_guienv=_device->getGUIEnvironment();
		this->gfARGB=argbunit;
		this->valueInit();
	}
	void steping(); // game loop
	void loopwork()
	{
		// Draw And Scene Line
		this->_driver->beginScene(true, true, SColor(this->gfARGB->getAlpha(),this->gfARGB->getRed(),this->gfARGB->getGreen(),this->gfARGB->getBlue()));
		this->_smgr->drawAll();
		this->_guienv->drawAll();
		this->fw->ppFrame();
	}
	void finalwork()
	{
		this->_driver->endScene();
	}
	void loginWork()
	{
		_driver->draw2DImage(_driver->getTexture("datas/login_screen.jpg"),core::position2d<s32>(0,0));
		if(nLoginWork==0)
		{
			IGUIButton *lgin=this->_guienv->addButton(rect<s32>(300,300,110,100),0,GUI_BUTTON_LOGINLEVEL_LOGINOK,L"Login",L"Login Now.");
			lgin->draw();
			nLoginWork++;
		}else{
		}
	}
	bool OnEvent(const SEvent &event);
};
It doesn't work !
it could be compiled well(with no error).
but, button is not displayed on screen.
how to fix my code ?
Eigen
Competition winner
Posts: 375
Joined: Fri Jan 27, 2006 2:01 pm
Location: Estonia
Contact:

Post by Eigen »

It's not displayed, because your button dimensions are off.

Correct usage would be

Code: Select all

rect<s32>(x1, y1, x2, y2)
not

Code: Select all

rect<s32>(x, y, width, height)
Use

rect<s32>(300,300,410,400) instead.
aktlakfh1777
Posts: 17
Joined: Sun Dec 21, 2008 1:40 am

Re...

Post by aktlakfh1777 »

thanks for your advice, but it still does not work.
Lil Margin
Posts: 212
Joined: Sun Jul 19, 2009 4:24 am
Location: Netherlands Antilles, Curacao

Post by Lil Margin »

1.make sure that nLoginWork==0 (or else it wont show the button offcourse)
2.try changing the add button position to something like this

Code: Select all

addButton(rect<s32>(10,240,110,240)
and see if the button displays...if not then your code is being misunderstanded by the compiler somewhere else in your code.









-Margin
Post Reply