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.
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Sat Dec 10, 2005 6:07 pm
Hello,
I´ve got a problem with my event receiver. If i use it, the whole programm crashes....what did I wrong?
here is my code:
Code: Select all
class EventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent (SEvent event)
{
if (!event.KeyInput.PressedDown)
{
switch (event.KeyInput.Key)
{
case KEY_KEY_A:
{
Key_A = true;
}
return true;
}
}
else
{
Key_A = false;
return false;
}
return false;
}
};
I get no compiler error, but it just doesn´t work. The bool Key_A is declared....
I hope, you can help me.
Regards Efrint
krama757
Posts: 451 Joined: Sun Nov 06, 2005 12:07 am
Post
by krama757 » Sat Dec 10, 2005 9:02 pm
You sure its not some problem in the rest of your application?
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Sat Dec 10, 2005 9:17 pm
yes, i´m shure. If i use the application without this event receiver, everything works fine.
jam
Posts: 409 Joined: Fri Nov 04, 2005 3:52 am
Post
by jam » Sun Dec 11, 2005 5:55 am
I tested your event reciever and I can not reproduce a crash, It works just fine here at least the way it's coded.
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Sun Dec 11, 2005 11:05 am
@bitplane yes I know what a "!" means...
@jam but why does it crash on my computer...I´ve got Visual studio 6, is that the problem?
I create my device like that:
Code: Select all
device = createDevice(EDT_DIRECTX9,dimension2d<s32>(x,y),32, true, true, true, &receiver);
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Mon Dec 12, 2005 5:47 pm
*bump*
does nobody know the solution?
bitplane
Admin
Posts: 3204 Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:
Post
by bitplane » Mon Dec 12, 2005 5:57 pm
okay this calls for another guess- from the code you've posted so far, you're attaching the wrong event handler to your device.
device = createDevice(EDT_DIRECTX9,dimension2d<s32>(x,y),32, true, true, true, &EventReceiver );
Guest
Post
by Guest » Tue Dec 13, 2005 4:19 pm
why? i n the line above the create device, i wrote:
Code: Select all
EventReceiver receiver;
if (DirectX == true)
{
device = createDevice(EDT_DIRECTX9,dimension2d<s32>(x,y),32, true, true, true, &receiver);
}
[/quote]
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Tue Dec 13, 2005 4:21 pm
ohh....i wasn´t logged in....but as i said in my post (as a guest)...
bitplane
Admin
Posts: 3204 Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:
Post
by bitplane » Tue Dec 13, 2005 5:47 pm
oops yea sorry my bad. still have no idea. try putting some printf's in to your event reciever to track down where the crash occurs
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Tue Dec 13, 2005 6:19 pm
i tried to comment parts of my eventreceiver with "//" out. But even, if the event receiver does nothing, everything crashes.
EDIT: The last line that is written in the consol is: Loaded Texture: #DefaultFont
EDIT#2: If I debug that, i get the message, that there is an untreated exception, an access violation....in this line....
1007E511 call dword ptr [edi+4]
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Wed Dec 14, 2005 5:26 pm
*bump*
EDIT: Even if i use the event receiver from the movement tutorial, i get the same error?! There must be an error in the rest of my code.
Efrint
Posts: 18 Joined: Sat Dec 10, 2005 6:04 pm
Post
by Efrint » Wed Dec 14, 2005 5:45 pm
I found my error. It was so easy.....I declared my event receiver local in a function. Thank you all for your help