In the last part of this chapter, we'll extend the particle system we've created in previous tutorials to emit the particles only when you are pressing down the left mouse button. We'll cover how to receive mouse events, how to check the state of the particle system, and decide whether to start or stop the emission:
1. First, we need to create an event receiver class which extends from the
IEventReceiver
class. Following is a simple modification from Irrlicht's mouse and joystick example tutorial. We just removed the joystick part:class MyEventReceiver : public IEventReceiver { public: //We'll create a struct to record info on the mouse state struct SMouseState { bool LeftButtonDown; SMouseState() : LeftButtonDown(false) { } } MouseState; virtual bool OnEvent(const SEvent& event) { if (event.EventType == irr::EET_MOUSE_INPUT_EVENT) { switch(event.MouseInput.Event) { case EMIE_LMOUSE_PRESSED_DOWN: MouseState.LeftButtonDown...