Funkin/source/CutsceneAnimTestState.hx

68 lines
1.6 KiB
Haxe
Raw Normal View History

2021-04-06 18:12:31 -04:00
package;
import flixel.FlxG;
import flixel.FlxSprite;
import flixel.FlxState;
import flixel.addons.display.FlxGridOverlay;
import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.math.FlxPoint;
import flixel.text.FlxText;
import flixel.util.FlxColor;
2021-04-22 11:19:55 -04:00
import openfl.Assets;
import openfl.display.BitmapData;
2021-04-22 11:19:55 -04:00
import openfl.display.MovieClip;
2021-04-23 07:30:39 -04:00
import openfl.geom.Matrix;
import openfl.geom.Rectangle;
2021-04-06 18:12:31 -04:00
class CutsceneAnimTestState extends FlxState
{
var cutsceneGroup:CutsceneCharacter;
var curSelected:Int = 0;
var debugTxt:FlxText;
2021-04-22 11:19:55 -04:00
var funnySprite:FlxSprite = new FlxSprite();
var clip:MovieClip;
2021-04-06 18:12:31 -04:00
public function new()
{
super();
var gridBG:FlxSprite = FlxGridOverlay.create(10, 10);
gridBG.scrollFactor.set(0.5, 0.5);
add(gridBG);
2021-04-08 20:48:11 -04:00
debugTxt = new FlxText(900, 20, 0, "", 20);
2021-04-06 18:12:31 -04:00
debugTxt.color = FlxColor.BLUE;
add(debugTxt);
2021-04-22 11:19:55 -04:00
clip = Assets.getMovieClip("tanky:");
2021-04-23 07:30:39 -04:00
//clip.x = FlxG.width/2;
//clip.y = FlxG.height/2;
2021-04-22 11:19:55 -04:00
FlxG.stage.addChild(clip);
funnySprite.x = FlxG.width/2;
2021-04-23 07:30:39 -04:00
funnySprite.y = FlxG.height/2;
2021-04-22 11:19:55 -04:00
add(funnySprite);
2021-04-06 18:12:31 -04:00
}
override function update(elapsed:Float)
{
super.update(elapsed);
2021-04-22 11:19:55 -04:00
2021-04-23 07:30:39 -04:00
// jam sprite into top left corner
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);
2021-04-22 11:19:55 -04:00
funnySprite.loadGraphic(funnyBmp);
2021-04-23 07:30:39 -04:00
// jam sprite back into place lol
funnySprite.offset.x = -bounds.x;
funnySprite.offset.y = -bounds.y;
2021-04-06 18:12:31 -04:00
}
}