1.

Solve : AS3 Rotating a sprite?

Answer»

Hey all,

I am in the process of MAKING a game using Actionscript 3 in FlashDevelop. In this game, you will have a player object located in a fixed position (for now..) on the screen and can control your player using your mouse. I want this sprite to ROTATE from it's CENTERPOINT and facing the mouse. I'm having a heck of a time getting this to work how I want it to, and the closest I can get is to get it to rotate from it's top left corner. I've googled for hours on the subject, but if anyone knows a good tutorial on this, or a snippet of code for me, that would be super helpful. Thank you I am not familiar with action-script (i wish i was), but is it possible to copy the sprite image file multiple times and have it partially rotated with your graphics editor

Then in your program have the sprite redrawn as the partially rotated sprite files?
Does this make sense? Seems the commonly accepted method is to put the bitmap in a sprite and rotate it that way:
Code: [SELECT]var spriteContainer:Sprite = NEW Sprite ();
bitmap.x = - bitmap.width / 2;
bitmap.y = - bitmap.height / 2;
spriteContainer.addChild (bitmap);
addChild (spriteContainer);
spriteContainer.rotation = 30; //put your rotation here



Discussion

No Comment Found