hello, i’m doing a 3d checkers game, using jmonkey only for 3d interface, have logic and controls in java old proyect.
is only a 3d view that implements view interfaces.
have things like this.
// Mueve fichas dentro del tablero, segun ficha origen y cuadrado de destino
public void movePiece(Point orig, Point dest){
// Move piece in board_pieces
final int rowOrig = orig.getX();
final int rowDest = dest.getX();
final int colOrig = orig.getY();
final int colDest = dest.getY();
//
Spatial piece = board_pieces[rowOrig][colOrig];
Geometry square = board_squares[rowDest][colDest];
//
board_pieces[rowDest][colDest] = piece;
board_pieces[rowOrig][colOrig] = null;
// Set New Piece Pos
piece.setUserData(“row_num”, rowDest);
piece.setUserData(“col_num”, colDest);
// Start Post Mid pos and end Pos
Vector3f origen = piece.getLocalTranslation();
Vector3f origen_up = new Vector3f(origen.x,origen.y+0.5f,origen.z);
Vector3f destino = square.getLocalTranslation();
Vector3f destino_up = new Vector3f(destino.x,destino.y+0.5f,destino.z);
Vector3f altura = new Vector3f((origen.x+destino.x)/2,origen.y+5f,(origen.z+destino.z)/2);
// Motion Path (camino del movimient)
MotionPath motionPath = new MotionPath();
motionPath.addWayPoint(origen);
motionPath.addWayPoint(origen_up);
motionPath.addWayPoint(altura);
motionPath.addWayPoint(destino_up);
motionPath.addWayPoint(destino);
motionPath.setCycle(false);
motionPath.setCurveTension(0.50f);
// Evento del movimiento
MotionEvent motionEvent = new MotionEvent(piece,motionPath);
// Motion Data
motionEvent.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionEvent.setInitialDuration(15f);
motionEvent.setSpeed(20f);
motionEvent.play();
}
and other like
// Quita una pieza del tablero
public void eatPiece(Point pos){
// Clear Piece Board
Spatial piece = board_pieces[pos.getX()][pos.getY()];
int row = piece.getUserData("row_num");
int col = piece.getUserData("col_num");
board_pieces[row][col] = null;
//
Vector3f origen = piece.getLocalTranslation();
Vector3f destino;
Vector3f altura = new Vector3f((origen.x+destino.x)/2,origen.y+10f,(origen.z+destino.z)/2);
Vector3f destino_down = new Vector3f(destino.x,destino.y-2f,destino.z);
// Motion Path (camino del movimient)
MotionPath motionPath = new MotionPath();
motionPath.addWayPoint(origen);
motionPath.addWayPoint(altura);
motionPath.addWayPoint(destino);
motionPath.addWayPoint(destino_down);
motionPath.setCycle(false);
motionPath.setCurveTension(0.50f);
// Evento del movimiento
MotionEvent motionControl = new MotionEvent(piece,motionPath);
// Motion Data
motionControl.setDirectionType(MotionEvent.Direction.PathAndRotation);
motionControl.setInitialDuration(25f);
motionControl.setSpeed(15f);
motionControl.play();
}
the game controllers can call this methods in sequential order
like
view.movePiece(orig,dest);
view.eatPiece(midPoint);
this is working, but the animations start simultaneously.
i need to wait for movePiece animation ends and after start eatPiece and wait to his end.
need some synchronization but only in the view side, can’t change game controller code.
some idea?= help!:
thanks.