Skip to content

Commit

Permalink
Embed autotile assets (#2402)
Browse files Browse the repository at this point in the history
  • Loading branch information
Geokureli authored Sep 9, 2021
1 parent 629d429 commit e3c3b30
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
Binary file modified assets/images/tile/autotiles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/images/tile/autotiles_alt.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion flixel/system/FlxAssets.hx
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ class FlxAssets
*/
public static inline function getBitmapFromClass(source:Class<Dynamic>):BitmapData
{
return Type.createInstance(source, [0, 0]);
return Type.createInstance(source, []);
}

/**
Expand Down
41 changes: 41 additions & 0 deletions flixel/tile/FlxTilemap.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,46 @@ import Std.is as isOfType;

using flixel.util.FlxColorTransformUtil;

#if html5
@:keep @:bitmap("assets/images/tile/autotiles.png")
private class RawGraphicAuto extends BitmapData {}
class GraphicAuto extends RawGraphicAuto
{
public function new (width = 128, height = 8, transparent = true, fillRGBA = 0xFFffffff, ?onLoad:Dynamic)
{
super(width, height, transparent, fillRGBA, onLoad);
// Set properties because `@:bitmap` constructors ignore width/height
this.width = width;
this.height = height;
}
}

@:keep @:bitmap("assets/images/tile/autotiles_alt.png")
private class RawGraphicAutoAlt extends BitmapData {}
class GraphicAutoAlt extends RawGraphicAutoAlt
{
public function new (width = 128, height = 8, transparent = true, fillRGBA = 0xFFffffff, ?onLoad:Dynamic)
{
super(width, height, transparent, fillRGBA, onLoad);
// Set again because `@:bitmap` constructors ignore width/height
this.width = width;
this.height = height;
}
}

@:keep @:bitmap("assets/images/tile/autotiles_full.png")
private class RawGraphicAutoFull extends BitmapData {}
class GraphicAutoFull extends RawGraphicAutoFull
{
public function new (width = 256, height = 48, transparent = true, fillRGBA = 0xFFffffff, ?onLoad:Dynamic)
{
super(width, height, transparent, fillRGBA, onLoad);
// Set again because `@:bitmap` constructors ignore width/height
this.width = width;
this.height = height;
}
}
#else
@:keep @:bitmap("assets/images/tile/autotiles.png")
class GraphicAuto extends BitmapData {}

Expand All @@ -41,6 +81,7 @@ class GraphicAutoAlt extends BitmapData {}

@:keep @:bitmap("assets/images/tile/autotiles_full.png")
class GraphicAutoFull extends BitmapData {}
#end

// TODO: try to solve "tile tearing problem" (1px gap between tile at certain conditions) on native targets

Expand Down

0 comments on commit e3c3b30

Please sign in to comment.