c# - xna zoom using mouse scroll wheel -


how zoom using mouse scroll wheel, got try this

        if (currentmousestate.scrollwheelvalue < originalmousestate.scrollwheelvalue)         {             cameraposition += new vector3(0, -1, 0);             updateviewmatrix();             currentmousestate.scrollwheelvalue.equals(0);         }         if (currentmousestate.scrollwheelvalue > originalmousestate.scrollwheelvalue)         {             cameraposition += new vector3(0, 1, 0);             updateviewmatrix();             currentmousestate.scrollwheelvalue.equals(0);         } 

but keep zooming in if scroll once , kinda new xna. please help.

scrollwheelvalue gets cumulative mouse scroll wheel value since game started, every time need copy value in variable, in order compare next cycle.

moreover, can't set scrollwheelvalue, , line wrong:

currentmousestate.scrollwheelvalue.equals(0); 

i think idea set value 0, instruction compares value 0 , gives boolean.

edit:
should this:

declare global variable

private int previousscrollvalue;

and set in initialize method as:

previousscrollvalue = originalmousestate.scrollwheelvalue;

then edit code this:

if (currentmousestate.scrollwheelvalue < previousscrollvalue) {     cameraposition += new vector3(0, -1, 0);     updateviewmatrix(); } else if (currentmousestate.scrollwheelvalue > previousscrollvalue) {     cameraposition += new vector3(0, 1, 0);     updateviewmatrix(); } previousscrollvalue = currentmousestate.scrollwheelvalue; 

it should work.


Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -