entities handling input

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • entities handling input

      Hi all, I am after some insight on a design issue i am having. I am writing a basic 2d game. The gameplay requires the user to click and drag the mouse on particular entities.

      I am after some insight on how i might handle this.
      At the moment (just to get it working) i have put the handling within scene nodes.
      The game view forwards messages to the scene, which forwards the messages to all scene nodes until one consumes it (or not).
      I do not want to keep it like this because scene nodes are meant for rendering.
      However it is convenient, because my scene nodes contain the data needed for 'screen position' of the entities which I am using for hit testing.

      I appreciate any advice, hints and ideas.

      Thanks in advance.
    • This is actually completely fine, scene nodes will contain more than just rendering code, it will also contain code for spatial partitioning, and graphical selection ie. selecting actors using the graphics pipeline. I see no reason not to use them for basic 2D box detection either.

      If you are using OpenGL or direct3D, consider using a selection technique such as a PBO selection, if not, ignore this.
      PC - Custom Built
      CPU: 3rd Gen. Intel i7 3770 3.4Ghz
      GPU: ATI Radeon HD 7959 3GB
      RAM: 16GB

      Laptop - Alienware M17x
      CPU: 3rd Gen. Intel i7 - Ivy Bridge
      GPU: NVIDIA GeForce GTX 660M - 2GB GDDR5
      RAM: 8GB Dual Channel DDR3 @ 1600mhz
    • I agree, rendering is just one use for a scene graph. It's really a data structure representing the visible geometry in your game. You definitely want to make it generic, but asking the question "what thing is here" is completely reasonable.

      -Rez