Style is the style. null for default style. message is the message. Not sure how else to describe the “text that appears in the message box”.
You have to make one. Add a text field, etc…
There are lots of applications that use Lemur if you want to look at examples. I suspect that it will be too much for you to look at because you seem to want to do as little reading as possible… and unfortunately, I do not have time for one-on-one “walk you through every step” tech support today.
I think all of these examples use Lemur in some way:
…some even have pop-up message boxes for entering text.
For a really complex example, you can also look here:
…but in the end, you will create a container, add the stuff you want to it, position it on screen, then GuiGlobals.getInstance().showModalPopup(yourContainer)
A small question for now : since I will use crosshair to take the scene in my game , so I need to ban the cursor when enter the scene. So I’m asking for the method to it.
And a small request that help me check why my listener broke down there. I’ve build a new thread to load model, then enqueue it to the main thread. And I don’t have any idea about that, I thought your check would be helpful. The source code is as below:
And when I tried to load the model in another thread then enqueue it to the main thread by give the value to it, it told that the spatial should be final. Why it would be final? And is there any solution to slove it?
Because you are using local variable inside a lambda expression, or anonymous classes (Runnable class)…local vars are protected from being used outside their major scope, if you need to force their use (although I don’t like to), specify a final pointer(array) from outside the runnable then fill it with values according to your needs.
Such a way(Pointers ) would be like :
private void loadShip(){
//specify a final pointer with fixed storage in memory, ie no future use of new keyword
final Spatial[] pointer = new Spatial[1];
app.enqueue(()->{
pointer[0] = assetManager.loadModel(model);//dereference the pointer here
});
}
Open a new thread for each separate problem, specifying the category, main problem, image or code.
Ask only one question per thread, so people won’t get lost, & respond quickly, plus others who know the answer would be notified of your question.
Because, I see this thread has over 3-4 questions from Nodes, collisions/physics, then lemur & now local vars, unless I read each comment here, I cannot help you out.
Could help me to check those methods? It cannot respond to my click.
It seems that the reDraw method or the listener get wrong but I can’t figure it out.
The first block here is the method I initialize & update the scene(the Spatial [][] that called temp [][])
//To load model according to the Status
public Spatial draw(int row,int col){
Spatial g = drawGrass();
if (status[row][col].equals(Status.Covered_with_Mine)|status[row][col].equals(Status.Covered_without_Mine)){
g=drawGrass();
}
if (status[row][col]==Status.Mine){
g=drawMine();
}
if (status[row][col]==Status.Flag){g=drawFlag();g.scale(0.25f);}
if (status[row][col]==Status.Clear){
g=drawNum(row,col);
}
//set location
g.scale(0.5f);
g.center();
float m=(float)(10.0*(row-5)+5.0);
float n=(float)(10.0*(col-5)+5.0);
g.setLocalTranslation(m,0.0f,-n);
return g;
}
//To reload each model
public void reDraw(int row,int col) {
new Thread () {
public void run() {
final Spatial tem= draw(row,col);
enqueue(new Runnable() {
public void run() {
temp[row][col]=tem;
}
});
}
}.start();
}
public void onOpen(int i,int j){
//prevent getting mine at the first try
if (gameController.getOpenCount()==1){
while (status[i][j].equals(Status.Covered_with_Mine)){mineField.resetMine();}
if (status[i][j].equals(Status.Covered_without_Mine)){status[i][j]=Status.Clear;}
gameController.addOpenCount();
}else {
if (status[i][j].equals(Status.Covered_with_Mine)){
gameController.find_mine();
gameController.getOnTurnPlayer().costScore();
makeExplosion(i,j);
status[i][j]=Status.Mine;
reDraw(i,j);
}
if (status[i][j].equals(Status.Covered_without_Mine)){status[i][j]=Status.Clear;}
gameController.addOpenCount();
}
reDraw(i,j);
gameController.nextTurn();
}
public void onMark(int i,int j){
if (status[i][j].equals(Status.Covered_with_Mine)){
gameController.find_mine();
status[i][j]=Status.Flag;
gameController.getOnTurnPlayer().addScore();
}
if (status[i][j].equals(Status.Covered_without_Mine)){
gameController.getOnTurnPlayer().addMistake();
status[i][j]=Status.Clear;
}
reDraw(i,j);
gameController.nextTurn();
}
The mouse clicks in picking method is working now.
So I thought the reload method is wrong since I’ve check that by write a restart method
Also, when I run the project, I got an warning:
log4j:WARN No appenders could be found for logger (com.simsilica.lemur.GuiGlobals).
log4j:WARN Please initialize the log4j system properly.
What is that about? I’ve add log4j to my dependency
If you look at any of the examples I provided in their build.gradle you can see the log4j related dependencies that you would need to make those warnings go away.
I found that on a tutorial at 第九章:用户交互, it tolds that we should firstly load the model in new thread then take it to the main thread by the method “enqueue”.
Yeh I can read this in English, but I have no idea about that site, all I know is when I do enqueue, it adds a new Callable FutureTask to an AppTasks stack via a runnable wrapper then pass that to the update method where each task when reaches its end it get closed & notifies the proceeding task to execute over…so when you do enqueue its already a thread…