Created
February 6, 2019 20:34
-
-
Save Geokureli/3eb0f77a3d7e46073639f52655750320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package vfx; | |
import flixel.FlxG; | |
import flixel.FlxSprite; | |
import flixel.graphics.FlxGraphic; | |
import flixel.graphics.frames.FlxTileFrames; | |
import flixel.math.FlxPoint; | |
import flixel.system.FlxAssets.FlxGraphicAsset; | |
import flixel.util.FlxBitmapDataUtil; | |
class SpriteUtil { | |
static public function loadAnimationWithSpaces( | |
sprite :FlxSprite, | |
source :FlxGraphicAsset, | |
tileSize :FlxPoint, | |
?tileSpacing:FlxPoint, | |
unique = false, | |
?key :String | |
):FlxSprite { | |
if (tileSpacing == null) | |
tileSpacing = FlxPoint.get(1, 1); | |
source = FlxBitmapDataUtil.addSpacesAndBorders( | |
FlxG.bitmap.add(source, false).bitmap, | |
tileSize, | |
tileSpacing | |
); | |
var graph:FlxGraphic = FlxG.bitmap.add(source, unique, key); | |
sprite.width = tileSize.x; | |
sprite.height = tileSize.y; | |
sprite.frames = FlxTileFrames.fromGraphic(graph, tileSize, null, tileSpacing); | |
return sprite; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment