-1

I'm trying to make asteroids that spin in my 2D game.

Using the graphics class I am drawing an image I created onto the screen (the asteroid) and moving it across the screen.

My next step was to make it rotate however I am lost at to how to do this.

I was able to make it rotate when I was simply drawing a polygon by changing the vertices of the asteroid however there are no vertices when drawing images, only (x,y) and (length,width).

How can I rotate an image? Is there any inbuilt functionality that does it?

I'm not asking for someone to tell me exactly how to do this, I'm just looking for a push in the right direction as I am a bit lost.

amit
  • 175,853
  • 27
  • 231
  • 333
Matt Walker
  • 47
  • 1
  • 9
  • You need to specify your exact problem, tell us how you attempted to achieve it, show us the results you are currently getting and show us the results you want. This is not a site to walk to through how to do things step by step; this is not a site to request tutorials. Please reformat your question to fit these requirements, showing your attempt – Vince Apr 28 '15 at 20:12

1 Answers1

1

Either use a AffineTransform or use Graphics#rotate. In either case, you should make a copy of the Graphics context first (Graphics#create) first, which will preserve the state of the original context. Just make sure you dispose of the copy when you're done (Graphics#dispose)

Something like this perhaps

Community
  • 1
  • 1
MadProgrammer
  • 343,457
  • 22
  • 230
  • 366