Stencyl lhas a block to spin the image instance, but then it is an instance instead of an image that we can upload.
This block code (Advanced -> Flow ) or Extension function can do the trick.
This is the code in an extension:
public static function RotateImage(bitmapData:BitmapData):BitmapData{
var degree=90;
var newBitmap:BitmapData = new BitmapData( bitmapData.height, bitmapData.width, true );
var matrix:Matrix = new Matrix();
matrix.rotate( degree*(Math.PI/180) );
if ( degree == 90 ) {
matrix.translate( bitmapData.height, 0 );
} else if ( degree == -90 || degree == 270 ) {
matrix.translate( 0, bitmapData.width );
} else if ( degree == 180 ) {
newBitmap = new BitmapData( bitmapData.width, bitmapData.height, true );
matrix.translate( bitmapData.width, bitmapData.height );
}
newBitmap.draw( bitmapData, matrix, null, null, null, true );
return newBitmap;
}
Geen opmerkingen:
Een reactie posten