Commit 02409af6 authored by Matyáš Latner's avatar Matyáš Latner

#45 Move dragged action to proper layer

parent 46d5b8a1
......@@ -54,12 +54,13 @@ public class InTheDarknessGame extends AbstractTablexiaGame<List<MapWidget>> imp
BONUS_LAYER (2, Touchable.disabled),
MAP_LAYER (3, Touchable.enabled),
BUTTON_LAYER (4, Touchable.enabled),
ACTIONS_LAYER (5, Touchable.enabled),
PLAYER_LAYER (6, Touchable.disabled),
INFO_LAYER (7, Touchable.enabled),
PLAYER_LAYER (5, Touchable.disabled),
INFO_LAYER (6, Touchable.enabled),
ACTIONS_LAYER (7, Touchable.enabled),
FADE_LAYER (8, Touchable.enabled),
KEY_LAYER (9, Touchable.enabled),
ACTION_STRIP_LAYER (10, Touchable.enabled);
ACTION_STRIP_LAYER (10, Touchable.enabled),
OVERLAY_LAYER (11, Touchable.enabled);
private static final int TOP_Z_INDEX = GameLayer.values().length + 1;
......
......@@ -208,10 +208,6 @@ public class Action extends TablexiaNoBlendingImage {
public void setClickable() {
setTouchable(Touchable.enabled);
// this.scene = scene;
// scene.registerTouchArea(this);
// scene.setTouchAreaBindingOnActionDownEnabled(true);
// clickable = true;
}
protected boolean downAction(float positionX, float positionY, boolean center) {
......@@ -223,7 +219,6 @@ public class Action extends TablexiaNoBlendingImage {
}
actionsStripWidget.setDraggedAction(this);
this.setZIndex(100);
// getParent().sortChildren(true);
draggable = true;
return true;
}
......@@ -236,7 +231,6 @@ public class Action extends TablexiaNoBlendingImage {
clickable = false;
draggable = false;
InTheDarknessGame.GameLayer.resetLayersZIndexes();
actionsStripWidget.setDraggedAction(null);
if (collidesWithNumber != NO_COLLISION_NUMBER) {
......@@ -312,17 +306,8 @@ public class Action extends TablexiaNoBlendingImage {
private void detachFromScene() {
removeListener(dragListener);
remove();
// if (scene != null) {
// scene.unregisterTouchArea(Action.this);
// }
// UtilityAccess.getInstance().detachAndAttachEntity(this, null, null, false);
}
protected void onDetachFomScene() {
// detachSelf();
}
private void performDropAction() {
for (ActionListener actionListener : actionListeners) {
actionListener.onActionDrop(Action.this, collidesWithNumber);
......
......@@ -228,10 +228,17 @@ public class ActionsWidget extends Group implements ActionListener {
@Override
public void onActionDrag(Action lastAction) {
lastAction.setVisible(false);
Vector2 stageCoordinates = lastAction.localToStageCoordinates(new Vector2());
InTheDarknessGame.GameLayer.OVERLAY_LAYER.getLayerEntity().stageToLocalCoordinates(stageCoordinates);
lastAction.setPosition(stageCoordinates.x, stageCoordinates.y);
InTheDarknessGame.GameLayer.OVERLAY_LAYER.getLayerEntity().addActor(lastAction);
lastAction.setVisible(true);
actions.remove(lastAction);
Action action = createAction(lastAction.getActionType(), lastAction.getOrderNumber(), false, inTheDarknessGame);
action.showWithAnimation();
prepareActionsReactionAreas(action);
action.showWithAnimation();
disableActions();
tryHideTutorialArrowSprite();
}
......@@ -275,9 +282,9 @@ public class ActionsWidget extends Group implements ActionListener {
showArrowSprite(action.getX() + action.getWidth(), action.getY() - action.getHeight() / 2);
action.setVisible(false);
Vector2 stageCoordinates = action.localToStageCoordinates(new Vector2());
InTheDarknessGame.GameLayer.ACTION_STRIP_LAYER.getLayerEntity().stageToLocalCoordinates(stageCoordinates);
InTheDarknessGame.GameLayer.OVERLAY_LAYER.getLayerEntity().stageToLocalCoordinates(stageCoordinates);
action.setPosition(stageCoordinates.x, stageCoordinates.y);
InTheDarknessGame.GameLayer.ACTION_STRIP_LAYER.getLayerEntity().addActor(action);
InTheDarknessGame.GameLayer.OVERLAY_LAYER.getLayerEntity().addActor(action);
action.setVisible(true);
}
}
......@@ -287,9 +294,9 @@ public class ActionsWidget extends Group implements ActionListener {
addActor(tutorialArrowImage);
tutorialArrowImage.setPosition(positionX + START_ARROW_X_OFFSET, positionY + START_ARROW_Y_OFFSET);
Vector2 stageCoordinates = tutorialArrowImage.localToStageCoordinates(new Vector2());
InTheDarknessGame.GameLayer.ACTION_STRIP_LAYER.getLayerEntity().stageToLocalCoordinates(stageCoordinates);
InTheDarknessGame.GameLayer.OVERLAY_LAYER.getLayerEntity().stageToLocalCoordinates(stageCoordinates);
tutorialArrowImage.setPosition(stageCoordinates.x, stageCoordinates.y);
InTheDarknessGame.GameLayer.ACTION_STRIP_LAYER.getLayerEntity().addActor(tutorialArrowImage);
InTheDarknessGame.GameLayer.OVERLAY_LAYER.getLayerEntity().addActor(tutorialArrowImage);
tutorialArrowImage.setVisible(true);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment