Bonjour,
J'essaye désespérément de faire tourner une image sur elle même :
Avec ce code j'obtiens ça:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 public class Game1 : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; Texture2D maTexture; Rectangle position; int rotation; protected override void Initialize() { this.graphics.IsFullScreen = false; this.graphics.PreferredBackBufferWidth = 800; this.graphics.PreferredBackBufferHeight = 600; this.graphics.ApplyChanges(); this.Window.Title = "Notre premier programme !"; this.Window.AllowUserResizing = false; position = new Rectangle(100, 100, 200, 200); rotation = 45; base.Initialize(); } protected override void LoadContent() { spriteBatch = new SpriteBatch(GraphicsDevice); maTexture = this.Content.Load<Texture2D>("carre"); } protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.LightSkyBlue); // TODO: Add your drawing code here spriteBatch.Begin(); spriteBatch.Draw(maTexture, position, null, Color.Violet); spriteBatch.Draw(maTexture, position, null, Color.White, MathHelper.ToRadians(rotation), new Vector2(position.Width /2, position.Height/2), SpriteEffects.None, 0); spriteBatch.End(); base.Draw(gameTime); } }
Le 2ème carré à fait une rotation correcte mais le centre des 2 devraient être parfaitement superposés...
Je ne comprends pas ou est l'erreur
Partager