Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Embed autotile assets #2402

Merged
merged 4 commits into from
Sep 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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, []);
Gama11 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
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
Gama11 marked this conversation as resolved.
Show resolved Hide resolved
@: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