The idea is to modify the FlxSprite:loadGraphic() method so that you can pass the number of rotations you want(replacing the Reverse parameter).
This implies modifying the FlxG:addBitmap(), FlxSprite:render() and FlxSprite:calcFrame() methods.
Here's the function that creates the rotation spritesheet from the original spritesheet, I'm sure there's a lot of room for improvement:
/**
* Creates a spritesheet with all the rotated frames
*
* @param bmd The source spritesheet
* @param fW Frame's width
* @param fH Frame's height
* @param numRotations Number of rotations to create(ex:4 rotates for angles: 0,90,180,270)
* @return The new spritesheet
*/
static public function rotationsBitmap(bmd:BitmapData,fW:uint,fH:uint,numRotations:uint):BitmapData {
//the size of each frame must be larger so rotations fit
var frameSize:int = Math.ceil(Math.max(fW,fH) * Math.SQRT2)
var tempBMD:BitmapData = new BitmapData(frameSize, frameSize, true, 0x00000000)
var tempBMD2:BitmapData = new BitmapData(frameSize, frameSize, true, 0x00000000)
var destP:Point = new Point((frameSize-fW) / 2, (frameSize-fH) / 2)
var destP2:Point = new Point()
var rect:Rectangle = new Rectangle(0, 0, 16, 16)
var rectZero:Rectangle = new Rectangle(0,0,frameSize,frameSize)
var mat:Matrix = new Matrix()
var numColumns:uint = bmd.width/fW
var numLines:uint = bmd.height/fH
var numFrames:uint = numColumns * numLines
//we try to make the bitmapdata as wide as possible (< 2800)
//so its less likely to go over the 2880 pixels limit for BitmapData
var neededLines:uint = Math.ceil((numFrames * frameSize)/2800)
var framesPerLine:uint = Math.ceil(numFrames / neededLines)
var newBMD:BitmapData = new BitmapData(framesPerLine*frameSize,frameSize*numRotations*neededLines,true,0x88880000)
for (var r:int = 0; r < numRotations; r++){
mat.identity()
mat.translate(-frameSize/2,-frameSize/2)
mat.rotate(r * (Math.PI * 2) / numRotations)
mat.translate(frameSize/2,frameSize/2)
for (var i:int = 0; i < numFrames; i++){
rect.x = (i%numColumns)*fW
rect.y = Math.floor(i/numColumns)*fH
tempBMD.fillRect(rectZero,0x00000000)
tempBMD.copyPixels(bmd, rect, destP)
tempBMD2.fillRect(rectZero,0x00000000)
tempBMD2.draw(tempBMD,mat)
destP2.x = (i%framesPerLine) * frameSize
destP2.y = (r * neededLines * frameSize) + (Math.floor(i/framesPerLine)*frameSize)
newBMD.copyPixels(tempBMD2, rectZero, destP2)
}
}
return newBMD
}
I suspect there may be a way to reduce the number of needed rotations, dividing it by 4, some hack to flip a frame horizontally or vertically. There has to be a way...