Skip to content

Commit a8de2c8

Browse files
committed
Fix bug preventing having two PreRotations with same source but different # of frames
1 parent 0f7935d commit a8de2c8

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

net/flashpunk/graphics/PreRotation.as

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@ package net.flashpunk.graphics
2626
*/
2727
public function PreRotation(source:*, frameCount:uint = 36, smooth:Boolean = false)
2828
{
29-
var r:BitmapData = _rotated[source];
29+
var r:BitmapData = null;
30+
31+
if (_rotated[source] && _rotated[source][frameCount]) {
32+
r = _rotated[source][frameCount];
33+
}
34+
3035
_frame = new Rectangle(0, 0, _size[source], _size[source]);
3136

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

3742
if (!r)
3843
{
44+
if (! _rotated[source]) {
45+
_rotated[source] = new Array();
46+
}
47+
3948
// produce a rotated bitmap strip
4049
var size:uint = _size[source] = Math.ceil(FP.distance(0, 0, temp.width, temp.height));
4150
_frame.width = _frame.height = size;
@@ -46,7 +55,7 @@ package net.flashpunk.graphics
4655
width = _MAX_WIDTH - (_MAX_WIDTH % _frame.width);
4756
height = Math.ceil(frameCount / (width / _frame.width)) * _frame.height;
4857
}
49-
_rotated[source] = r = new BitmapData(width, height, true, 0);
58+
_rotated[source][frameCount] = r = new BitmapData(width, height, true, 0);
5059
var m:Matrix = FP.matrix,
5160
a:Number = 0,
5261
aa:Number = (Math.PI * 2) / -frameCount,

0 commit comments

Comments
 (0)