List of usage examples for com.badlogic.gdx.scenes.scene2d.ui ImageButton getStyle
public ImageButtonStyle getStyle()
From source file:es.eucm.ead.engine.processors.controls.ImageButtonProcessor.java
License:Open Source License
@Override public Component getComponent(ImageButton component) { // Create the component ControlComponent controlComponent = gameLoop.createComponent(ControlComponent.class); // Load basic skin for the image component Skin skin = gameAssets.getSkin();// w ww. j a v a2s . c o m final ImageButtonStyle imageButtonStyle = new ImageButtonStyle( skin.get(component.getStyle(), ImageButtonStyle.class)); com.badlogic.gdx.scenes.scene2d.ui.ImageButton button = new com.badlogic.gdx.scenes.scene2d.ui.ImageButton( imageButtonStyle); controlComponent.setControl(button); // If the imageUp is defined, load it and add it to style if (component.getImageUp() != null) { gameAssets.get(component.getImageUp(), Texture.class, new Assets.AssetLoadedCallback<Texture>() { @Override public void loaded(String fileName, Texture asset) { imageButtonStyle.imageUp = new TextureRegionDrawable(new TextureRegion(asset)); } @Override public void error(String fileName, Class type, Throwable exception) { Gdx.app.error("ImageButtonProcessor", "Impossible to load " + fileName, exception); } }); } // If the imageDown is defined, load it and add it to style if (component.getImageDown() != null) { gameAssets.get(component.getImageDown(), Texture.class, new Assets.AssetLoadedCallback<Texture>() { @Override public void loaded(String fileName, Texture asset) { imageButtonStyle.imageDown = new TextureRegionDrawable(new TextureRegion(asset)); } @Override public void error(String fileName, Class type, Throwable exception) { Gdx.app.error("ImageButtonProcessor", "Impossible to load " + fileName, exception); } }); } return controlComponent; }