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

FlxAtlasFrames.fromTexturePackerJson(): allow passing a parsed description #2021

Merged
merged 3 commits into from
Jan 11, 2017
Merged

FlxAtlasFrames.fromTexturePackerJson(): allow passing a parsed description #2021

merged 3 commits into from
Jan 11, 2017

Conversation

MSGhero
Copy link
Member

@MSGhero MSGhero commented Jan 2, 2017

Closes #2019

In case the JSON is already parsed to an object, this avoids hundreds of thousands of allocations for big spritesheets.

In case the JSON is already parsed
Ugh
@Gama11
Copy link
Member

Gama11 commented Jan 2, 2017

Hm.. I guess there isn't really a way to avoid Dynamic here?

A unit test would be nice. IIRC, we already have some for fromTexturePackerJson().

@Gama11
Copy link
Member

Gama11 commented Jan 2, 2017

I wonder whether it'd make sense to use OneOfTwo<String, Dynamic> here. Of course it doesn't add any type safety, but it might serve as self-documentation in a way.

@MSGhero
Copy link
Member Author

MSGhero commented Jan 2, 2017

I guess the most type-safe way to handle the dynamic is to expect the frames property. Could also be a private typedef TPObject if this looks gross.

OneOfTwo<String, { frames : Array<Dynamic> }>

@Gama11
Copy link
Member

Gama11 commented Jan 2, 2017

Is it really guruanteed to be an array? There's some code for "JSON-Hash".

@MSGhero
Copy link
Member Author

MSGhero commented Jan 2, 2017

Oh dang, I meant frames : Dynamic which is better than nothing. It would prevent you from putting 5 there, at least.

@Gama11
Copy link
Member

Gama11 commented Jan 2, 2017

Yeah, that seems sensible.

@MSGhero
Copy link
Member Author

MSGhero commented Jan 2, 2017

👍 I think, I haven't run unit tests locally in a while.

@Gama11 Gama11 changed the title Resolution to #2019 FlxAtlasFrames.fromTexturePackerJson(): allow passing a parsed description Jan 11, 2017
@Gama11 Gama11 merged commit 402b34f into HaxeFlixel:dev Jan 11, 2017
@MSGhero MSGhero deleted the tp-json branch January 14, 2017 21:37
Aurel300 pushed a commit to larsiusprime/haxeflixel that referenced this pull request Apr 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants