Created
April 29, 2016 08:10
-
-
Save Zolomon/8762fb045c34c082009a487ad98875b5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class RenderingSystem extends SortedIteratingSystem { | |
| private ComponentMapper<RenderableComponent> rm; | |
| private ComponentMapper<PositionComponent> pm; | |
| public RenderingSystem() { | |
| super(Family.all(RenderableComponent.class, PositionComponent.class).get(), new ZComparator()); | |
| rm = ComponentMapper.getFor(RenderableComponent.class); | |
| pm = ComponentMapper.getFor(PositionComponent.class); | |
| } | |
| protected void processEntity(Entity entity, float deltaTime) { | |
| // Render the entity | |
| } | |
| private static class ZComparator implements Comparator<Entity> { | |
| @Override | |
| public int compare(Entity e1, Entity e2) { | |
| return (int)Math.signum(pm.get(e1).z - pm.get(e2).z); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment