czyzby/gdx-lml

How to dispose batch of stage?

roleyzhang opened this issue · 2 comments

Hi,
Firstly, I used gdx-setup to generate a project with templates "Autumn MVC +Box2D+ VisUI".
Then I tried to add a background pic in loading stage, my code is below:
`import com.badlogic.gdx.Gdx;¬
import com.badlogic.gdx.graphics.Texture;¬
import com.badlogic.gdx.scenes.scene2d.Stage;¬

import com.github.czyzby.autumn.annotation.Inject;¬
¬
import com.github.czyzby.autumn.mvc.component.asset.AssetService;¬
import com.github.czyzby.autumn.mvc.component.ui.controller.ViewRenderer;¬
import com.github.czyzby.autumn.mvc.stereotype.View;¬
¬
import com.github.czyzby.kiwi.log.Logger;¬
import com.github.czyzby.kiwi.log.LoggerService;¬
¬
import com.github.czyzby.lml.annotation.LmlActor;¬
import com.kotcrab.vis.ui.widget.VisProgressBar;¬
/** Thanks to View annotation, this class will be automatically found and initiated.¬

  • This is the first application's view, shown right after the application starts. It will hide after all assests are¬
  • loaded.
    @view(value = "ui/templates/loading.lml", first = true)¬
    public class LoadingController implements ViewRenderer {¬
    private final Logger logger = LoggerService.forClass(LoadingController.class);¬
    private Texture bground = new Texture(Gdx.files.internal("pic/bg1.jpg"));¬
    /
    * Will be injected automatically. Manages assets. Used to display loading progress.
    @Inject private AssetService assetService;¬
    /
    * This is a widget injected from the loading.lml template. "loadingBar" is its ID. */¬
    @LmlActor("loadingBar") private VisProgressBar loadingBar;¬

// Since this class implements ViewRenderer, it can modify the way its view is drawn. Additionally to drawing the¬
// stage, this view also updates assets manager and reads its progress.¬
@OverRide¬
public void render(final Stage stage, final float delta) {¬
assetService.update();¬
logger.info(assetService);¬ 6 logger.info(assetService.getLoadingProgress());¬
loadingBar.setValue(assetService.getLoadingProgress());¬
stage.act(delta);¬
stage.getBatch().begin();¬
stage.getBatch().draw(bground, 0, 0, 1920, 1080);¬
stage.getBatch().end();¬
stage.draw();¬

}¬`

The background added in the loading stage successful, but there is no way to dispose the batch of loading stage. I am a novice, read the document said batch need to be disposed after each use, I do not know should I need to dispose stage batch? Or the Autumn has been able to handle this, do not need me to dispose batch manually? Thanks!

Yes, I believe Autumn MVC disposes of the batch during destruction of the InterfaceService. It's already handled for you.

Thank you so much! MJ