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

New 'Shape' display object to procedurally draw lines (with rounded caps) #235

Closed
wants to merge 9 commits into from
Closed

Conversation

GameOverture
Copy link

I've made a 'Shape' class that extends from 'Sprite' that will allow the user to create custom shapes (like lines, rectangles, circles, and polygons) by assembling various primitives together, which can then be transformed like any 'Sprite' object.

For instance, this new 'Shape' object would be instantiated, then by calling its methods it would append new primitives to its local origin. The 'Shape' could then be told to ease, rotate, etc. and all the attached primitives would move relatively to each other.

The pull request includes a new file "Shape.hx" that resides in the 'display' package, and some modifications to the three 'Graphics' renderers (canvas, webGL, stage3D). Canvas implementation was straight forward. As for the other two, I've ensured to stay consistent with the current underlying architecture of drawing with quads, and the lines/caps are essentially just a series of fancy fillRect's that share the same vertex buffer attributes and shader.

Note: This pull request has changes to "Library.hx" and "Flipbook.hx" which are unrelated (and can be omitted) to this merge. I mentioned in an email to Bruno a couple weeks ago that I needed to write support for an in-house sprite tool, and he mentioned I should use Library.fromFlipbooks(). I had to however support data-driven animation names, (not hardcoded, parameterized dynamic variables) so I opted to write an alternate version of the method that took an Array instead.

Sorry for the long-winded description, hope you find it useful!
-Jay

…ather than Dynamic<Flipbook>. This was done because there was no means of naming each animation through a data-driven pipeline (aka the name had to be hardcoded). I also added a name field to the Flipbook which is now used when creating a Library with Flipbook array
…tives together and can be transformed like any Sprite object. Currently it only supports line segments (with rounded caps), but can be easily enhanced to do other shapes like rectangles and circles.
@GameOverture
Copy link
Author

Ugh, sorry I'm new with git and github... it looks like I should have made a separate branch so I could isolate only the 'Shape' changes, rather than trying to merge my master branch.

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.

1 participant