mirror of
https://github.com/ninjamuffin99/Funkin.git
synced 2024-11-05 06:14:36 +00:00
dope sprite bounds
This commit is contained in:
parent
fea40412ec
commit
356a9ad337
|
@ -11,6 +11,8 @@ import flixel.util.FlxColor;
|
||||||
import openfl.Assets;
|
import openfl.Assets;
|
||||||
import openfl.display.BitmapData;
|
import openfl.display.BitmapData;
|
||||||
import openfl.display.MovieClip;
|
import openfl.display.MovieClip;
|
||||||
|
import openfl.geom.Matrix;
|
||||||
|
import openfl.geom.Rectangle;
|
||||||
|
|
||||||
class CutsceneAnimTestState extends FlxState
|
class CutsceneAnimTestState extends FlxState
|
||||||
{
|
{
|
||||||
|
@ -35,11 +37,12 @@ class CutsceneAnimTestState extends FlxState
|
||||||
add(debugTxt);
|
add(debugTxt);
|
||||||
|
|
||||||
clip = Assets.getMovieClip("tanky:");
|
clip = Assets.getMovieClip("tanky:");
|
||||||
clip.x = FlxG.width/2;
|
//clip.x = FlxG.width/2;
|
||||||
clip.y = FlxG.height/2;
|
//clip.y = FlxG.height/2;
|
||||||
FlxG.stage.addChild(clip);
|
FlxG.stage.addChild(clip);
|
||||||
|
|
||||||
funnySprite.x = FlxG.width/2;
|
funnySprite.x = FlxG.width/2;
|
||||||
|
funnySprite.y = FlxG.height/2;
|
||||||
add(funnySprite);
|
add(funnySprite);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -48,8 +51,17 @@ class CutsceneAnimTestState extends FlxState
|
||||||
{
|
{
|
||||||
super.update(elapsed);
|
super.update(elapsed);
|
||||||
|
|
||||||
var funnyBmp:BitmapData = new BitmapData(FlxG.width, FlxG.height, true, 0x00000000);
|
// jam sprite into top left corner
|
||||||
funnyBmp.draw(clip, clip.transform.matrix, true);
|
var drawMatrix:Matrix = clip.transform.matrix;
|
||||||
|
var bounds:Rectangle = clip.getBounds(null);
|
||||||
|
drawMatrix.tx = -bounds.x;
|
||||||
|
drawMatrix.ty = -bounds.y;
|
||||||
|
// make bitmapdata only as big as it needs to be
|
||||||
|
var funnyBmp:BitmapData = new BitmapData(Math.ceil(bounds.width), Math.ceil(bounds.height), true, 0x00000000);
|
||||||
|
funnyBmp.draw(clip, drawMatrix, true);
|
||||||
funnySprite.loadGraphic(funnyBmp);
|
funnySprite.loadGraphic(funnyBmp);
|
||||||
|
// jam sprite back into place lol
|
||||||
|
funnySprite.offset.x = -bounds.x;
|
||||||
|
funnySprite.offset.y = -bounds.y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue