c# - XNA game Development, update sprite -


would tell did wrong in code...i trying move sprite whenever left arrow on keyboard pressed. when run code game window open , shut off prtty quickly

public class sprite {     private texture2d texture;     private vector2 position;      public sprite(texture2d texture, vector2 position)     {         // todo: complete member initialization         this.texture = texture;         this.position = position;     }      public void draw(spritebatch spritebatch)     {         spritebatch.draw(texture, position, color.white);     }      void update(keyboardstate keyboardstate, gametime gametime)     {         // throw new notimplementedexception();         if (keyboardstate.iskeydown(keys.left))         {             velocity = new vector2(-1, 0);             position+= ((velocity) *(float) gametime.elapsedgametime.totalseconds);         }     }     public vector2 velocity { get; set; }  } 


Comments

Popular posts from this blog

user interface - Python attempting to create a simple gui, getting "AttributeError: 'MainMenu' object has no attribute 'intro_screen'" -

jquery - Common JavaScript snippet to share files on Google Drive, Dropbox, Box.net or SkyDrive -

Android Gson.fromJson error -