Кто-нибудь может привести пример добавления таблицы и актеров в таблице на сцену в другом классе?
Libgdx Scene2D: добавить таблицу в отдельный класс
Ответы (1)
Вы можете пройти этап в качестве эталона или сдать стол
public class TableHandler {
public Table getAwesomeTable()
{
Table table = new Table();
//.. do stuff with table
//return table
return table;
}
public static Table getTableWithoutInstancingThisClass()
{
Table table = new Table();
//.. do stuff with table
//return table
return table;
}
public static void handMeTheStageToAlterIt(Stage stage)
{
//stage is passed as reference,
// as long as you don't give it a new Stage object you can alter it.
stage.addActor(...);
}
}
public class MyScreen implements Screen {
Stage stage;
@Override
public void show() {
stage = new Stage();
stage.addActor(TableHandler.getTableWithoutInstancingThisClass());
TableHandler.handMeStageToAlterIt(stage);
//instance tableHandler to get none static members.
TableHandler tableHandler = new TableHandler();
stage.addActor(tableHandler.getAwesomeTable());
}
}
person
Madmenyo
schedule
02.08.2015
Вы должны принять ответ и рассмотреть вопрос о голосовании;).
- person Madmenyo; 02.08.2015