{"action":"closed","issue":{"url":"https://api.github.com/repos/libgdx/ashley/issues/208","labels_url":"https://api.github.com/repos/libgdx/ashley/issues/208/labels{/name}","comments_url":"https://api.github.com/repos/libgdx/ashley/issues/208/comments","events_url":"https://api.github.com/repos/libgdx/ashley/issues/208/events","html_url":"https://github.com/libgdx/ashley/issues/208","id":126794541,"number":208,"title":"Before-after update methods in IteratingSystem","user":{"login":"rpazyaquian","id":5279463,"avatar_url":"https://avatars.githubusercontent.com/u/5279463?v=3","gravatar_id":"","url":"https://api.github.com/users/rpazyaquian","html_url":"https://github.com/rpazyaquian","followers_url":"https://api.github.com/users/rpazyaquian/followers","following_url":"https://api.github.com/users/rpazyaquian/following{/other_user}","gists_url":"https://api.github.com/users/rpazyaquian/gists{/gist_id}","starred_url":"https://api.github.com/users/rpazyaquian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rpazyaquian/subscriptions","organizations_url":"https://api.github.com/users/rpazyaquian/orgs","repos_url":"https://api.github.com/users/rpazyaquian/repos","events_url":"https://api.github.com/users/rpazyaquian/events{/privacy}","received_events_url":"https://api.github.com/users/rpazyaquian/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-01-15T02:30:18Z","updated_at":"2016-01-15T02:36:24Z","closed_at":"2016-01-15T02:36:24Z","body":"I think it'd be convenient to add a version of `IteratingSystem` that has overrideable callback methods that run before the main body of `update`. I wanted to use an `IteratingSystem` to render all my sprites in a single batch, instead of opening and closing a new batch every time `processEntity` was run. So I tried to override `update`, like so:\r\n\r\n```java\r\npublic class RenderSystem extends IteratingSystem {\r\n\r\n    private SpriteBatch batch;\r\n    private OrthographicCamera camera;\r\n\r\n    private ComponentMapper<PositionComponent> pm = Mappers.position;\r\n    private ComponentMapper<TextureComponent> tm = Mappers.texture;\r\n\r\n    public RenderSystem(OrthographicCamera camera) {\r\n        super(Family.all(PositionComponent.class, TextureComponent.class).get());\r\n\r\n        batch = new SpriteBatch();\r\n        this.camera = camera;\r\n    }\r\n\r\n    @Override\r\n    public void update(float deltaTime) {\r\n        camera.update();\r\n\r\n        batch.begin();\r\n\r\n        batch.setProjectionMatrix(camera.combined);\r\n        super(deltaTime);  // yes, i know this doesn't work the way i think it does\r\n        batch.end();\r\n    }\r\n\r\n    @Override\r\n    protected void processEntity(Entity entity, float deltaTime) {\r\n\r\n    }\r\n}\r\n```\r\n\r\nIt didn't work, for obvious reasons. Replacing the `super` call with the contents of `IteratingSystem`'s `update` method seemed redundant, and I considered extending `IteratingSystem` and just adding `beforeUpdate` and `afterUpdate` methods, but I was talked out of it by people who are better at OOP than I am. So, at the moment, the current solution is to just do it the normal way via extending `EntitySystem` and handling the convenience methods yourself.\r\n\r\nIs this something that could potentially be of use, or is it inadvisable for some reason?"}}