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

Easier extension of FlxTypedTilemap and FlxTile #3154

Merged
merged 1 commit into from
May 29, 2024

Conversation

Geokureli
Copy link
Member

@Geokureli Geokureli commented May 28, 2024

It's now easier to extend FlxTypedTilemap, all you need now is to override createTile, like so:

class SpecialTile extends FlxTile
{
    public var specialField:SpecialType;
    
    public function new (tilemap:SpecialTilemap, index, width, height, visible, allowCollisions)
    {
        this.specialField = Global.getSpecialValue(index);
        
        super(cast tilemap, index, width, height, visible, allowCollisions);
    }
}

class SpecialTilemap extends FlxTypedTilemap<SpecialTile>
{
    override function createTile(index, width, height, visible, allowCollisions)
    {
        return new SpecialTile(this, index, width, height, visible, allowCollisions);
    }
}

you can also use the existing method, which is to override initTileObjects and create all the tiles, there

@Geokureli Geokureli merged commit 2af1238 into HaxeFlixel:dev May 29, 2024
11 checks passed
@Geokureli Geokureli added this to the 5.9.0 milestone May 30, 2024
@Geokureli Geokureli deleted the typed-tilemap-2 branch June 11, 2024 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant