.net - Moving an image when clicked on by the mouse in a C# XNA game -


I have to move only one image when I click with the mouse.

I have for this movement:

  if (mouse. Gatestate). LeftButton == buttonstate pressed and pressed. Masterstate. Left button! = Buttonstate pressed ) {Xpos = rnd.ext (Window Bucket - Texture Rule); Ypos = rnd. Next (windowHeight - texture.Height); } PreviousMouseState = Mouse Gatestate ();   

But if I need to create some type of compound if argument, then it only runs when texture is clicked.

I think your texture object is just a texture2D < / Code> is not.

While drawing a phantom, you have to do some things that are both position and size:

  var currentMouseState = Mouse.GetState (); If (present mhousestate.litt button == buttonstate.transfer and previous homestate. Left button! = Buttonstate is pressed) {Vector 2 mousepage = New vector 2 (current moustestate.x, runoffstate.i); MousePosition- = sprite.Position; /// Bond is a property of texture, and returns a rectangle () struct var spriteWasClicked = sprite.Bounds.Contains (mousePosition.X, mousePosition.Y); If (Street Vascular) {xpos = rnd. Next (Window Up - Texture Ritual); Ypos = rnd. Next (windowHeight - texture.Height); // updated phantom position with xpos, here ypos}} PreviousMouseState = currentMouseState;    

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -