XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

Making the sprite's image turn by an angle

Last post 07/11/2009 16:52 by JasonD. 4 replies.
  • 07/11/2009 6:54

    Making the sprite's image turn by an angle

    I'm making a version of the game Tank and I am using the mouse to set the angle of my turret.  The problem is that I don't know how to make the turret turn to the angle so it looks in the right direction.  How do I make the turret spin? Do I have to make many pictures of the turrets multiple positions?
  • 07/11/2009 6:59 In reply to

    Re: Making the sprite's image turn by an angle

    No, just use SpriteBatch.Draw() with a rotation != 0.
  • 07/11/2009 7:10 In reply to

    Re: Making the sprite's image turn by an angle

    Thanks can someone tell me the exact syntax please.
  • 07/11/2009 7:28 In reply to

    Re: Making the sprite's image turn by an angle

    Use one of these 3 overloads:

            public void Draw(Texture2D texture, Rectangle destinationRectangle, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, SpriteEffects effects, float layerDepth); 
            public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, float scale, SpriteEffects effects, float layerDepth); 
            public void Draw(Texture2D texture, Vector2 position, Rectangle? sourceRectangle, Color color, float rotation, Vector2 origin, Vector2 scale, SpriteEffects effects, float layerDepth); 
     

    Game hobbyist hell-bent on coding a diabolical Matrix
  • 07/11/2009 16:52 In reply to

    Re: Making the sprite's image turn by an angle

    venator:
    Thanks can someone tell me the exact syntax please.
    Type SpriteBatch.Draw() and cursor over the Draw, and press F1 or F12.  The best way to learn is to look up the details from MSDN yourself.  It's a good habit to get used to.
Page 1 of 1 (5 items) Previous Next