Skip to content

Commit

Permalink
Fix bug preventing having two PreRotations with same source but diffe…
Browse files Browse the repository at this point in the history
…rent # of frames
  • Loading branch information
Draknek committed Mar 2, 2014
1 parent 0f7935d commit a8de2c8
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions net/flashpunk/graphics/PreRotation.as
Expand Up @@ -26,7 +26,12 @@ package net.flashpunk.graphics
*/
public function PreRotation(source:*, frameCount:uint = 36, smooth:Boolean = false)
{
var r:BitmapData = _rotated[source];
var r:BitmapData = null;

if (_rotated[source] && _rotated[source][frameCount]) {
r = _rotated[source][frameCount];
}

_frame = new Rectangle(0, 0, _size[source], _size[source]);

var temp:BitmapData = (source is BitmapData) ? source : FP.getBitmap(source);
Expand All @@ -36,6 +41,10 @@ package net.flashpunk.graphics

if (!r)
{
if (! _rotated[source]) {
_rotated[source] = new Array();
}

// produce a rotated bitmap strip
var size:uint = _size[source] = Math.ceil(FP.distance(0, 0, temp.width, temp.height));
_frame.width = _frame.height = size;
Expand All @@ -46,7 +55,7 @@ package net.flashpunk.graphics
width = _MAX_WIDTH - (_MAX_WIDTH % _frame.width);
height = Math.ceil(frameCount / (width / _frame.width)) * _frame.height;
}
_rotated[source] = r = new BitmapData(width, height, true, 0);
_rotated[source][frameCount] = r = new BitmapData(width, height, true, 0);
var m:Matrix = FP.matrix,
a:Number = 0,
aa:Number = (Math.PI * 2) / -frameCount,
Expand Down

0 comments on commit a8de2c8

Please sign in to comment.