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

java - How to Configure JAXRS and Spring With Annotations -

visual studio - TFS will not accept changes I've made to a Java project -

php - Create image in codeigniter on the fly -