so, what i want to do is make the camera move when the players presses a key. i've made these codes:
directly in the class:
Code: Select all
static EventProcesser ep;
Code: Select all
public class EventProcesser : Irrlicht.IEventReceiver
{
private bool[] keyboard_down;
public EventProcesser()
{
}
public bool OnEvent(Event e) {
if (e.Type == EventType.KeyInput)
{
keyboard_down[(int) e.Key] = e.KeyPressedDown;
return true;
}
return false;
}
public bool KeyDown(KeyCode k) {
return keyboard_down[(int) k];
}
}
Code: Select all
// events
ep = new EventProcesser();
device.EventReceiver = ep;
Code: Select all
// move the camera
if(ep.KeyDown(KeyCode.KEY_UP)) { // THIS LINE
camera_position.Y -= 1;
}
if(ep.KeyDown(KeyCode.KEY_DOWN)) {
camera_position.Y += 1;
}
Exception System.NullReferenceException was thrown in debugee:
Object reference not set to an instance of an object.
anyone care to help an OOP and Irrlicht noob? many thanks in advance
EDIT: on a side note, i don't really understand what 'static' does. i only know that i need to call some of the vars in my main class (e.g. 'device') from other classes directly