Commit 86d3532e authored by Luboš Horáček's avatar Luboš Horáček

Merge branch 'devel' of gitlab.labs.nic.cz:labs/tablexia into devel

parents ac81c9b6 73191f5e
obb/potme/gfx/actions/dog.png

7.38 KB | W: | H:

obb/potme/gfx/actions/dog.png

10.3 KB | W: | H:

obb/potme/gfx/actions/dog.png
obb/potme/gfx/actions/dog.png
obb/potme/gfx/actions/dog.png
obb/potme/gfx/actions/dog.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -33,7 +33,11 @@ import org.andengine.entity.Entity; ...@@ -33,7 +33,11 @@ import org.andengine.entity.Entity;
import org.andengine.entity.IEntity; import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.AlphaModifier; import org.andengine.entity.modifier.AlphaModifier;
import org.andengine.entity.modifier.DelayModifier; import org.andengine.entity.modifier.DelayModifier;
import org.andengine.entity.modifier.FadeInModifier;
import org.andengine.entity.modifier.FadeOutModifier;
import org.andengine.entity.modifier.LoopEntityModifier;
import org.andengine.entity.modifier.MoveModifier; import org.andengine.entity.modifier.MoveModifier;
import org.andengine.entity.modifier.SequenceEntityModifier;
import org.andengine.entity.primitive.Rectangle; import org.andengine.entity.primitive.Rectangle;
import org.andengine.entity.scene.Scene; import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background; import org.andengine.entity.scene.background.Background;
...@@ -213,6 +217,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -213,6 +217,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private boolean enabled = true; private boolean enabled = true;
private Entity backgroundLayer; private Entity backgroundLayer;
private Entity blinkerLayer;
private Entity textLayer; private Entity textLayer;
private Rectangle touchArea; private Rectangle touchArea;
...@@ -221,6 +226,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -221,6 +226,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private Sprite unpressedButtonSprite; private Sprite unpressedButtonSprite;
private Sprite disabledButtonSprite; private Sprite disabledButtonSprite;
private Sprite blinkerButtonSprite;
private Text buttonText; private Text buttonText;
private float textUnpressedPositionX; private float textUnpressedPositionX;
...@@ -228,17 +234,25 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -228,17 +234,25 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private float textPressedPositionX; private float textPressedPositionX;
private float textPressedPositionY; private float textPressedPositionY;
private LoopEntityModifier blinkerModifier;
public StartButton(VertexBufferObjectManager vertexBufferObject) { public StartButton(VertexBufferObjectManager vertexBufferObject) {
// layers // layers
backgroundLayer = new Entity(); backgroundLayer = new Entity();
blinkerLayer = new Entity();
textLayer = new Entity(); textLayer = new Entity();
attachChild(backgroundLayer); attachChild(backgroundLayer);
attachChild(blinkerLayer);
attachChild(textLayer); attachChild(textLayer);
// backgrounds // backgrounds
unpressedButtonSprite = new Sprite(0, 0, ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_START_UNPRESSED), vertexBufferObject); unpressedButtonSprite = new Sprite(0, 0, ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_START_UNPRESSED), vertexBufferObject);
disabledButtonSprite = new Sprite(0, 0, ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_START_DISABLED), vertexBufferObject); disabledButtonSprite = new Sprite(0, 0, ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_START_DISABLED), vertexBufferObject);
blinkerButtonSprite = new Sprite(0, 0, ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_START_BLINKER), vertexBufferObject);
disablePulsing();
blinkerLayer.attachChild(blinkerButtonSprite);
// touch area // touch area
touchArea = new Rectangle(0, 0, unpressedButtonSprite.getWidth(), unpressedButtonSprite.getHeight(), vertexBufferObject) { touchArea = new Rectangle(0, 0, unpressedButtonSprite.getWidth(), unpressedButtonSprite.getHeight(), vertexBufferObject) {
...@@ -273,11 +287,31 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener ...@@ -273,11 +287,31 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
} }
public void disable() { public void disable() {
disablePulsing();
enabled = false; enabled = false;
changeActualButtonSprite(disabledButtonSprite); changeActualButtonSprite(disabledButtonSprite);
buttonText.setPosition(textPressedPositionX, textPressedPositionY); buttonText.setPosition(textPressedPositionX, textPressedPositionY);
} }
public void enablePulsing() {
FadeInModifier fadeIn = new FadeInModifier(1f);
fadeIn.setAutoUnregisterWhenFinished(true);
FadeOutModifier fadeOut = new FadeOutModifier(1f);
fadeOut.setAutoUnregisterWhenFinished(true);
SequenceEntityModifier sequenceModifier = new SequenceEntityModifier(fadeOut, fadeIn);
sequenceModifier.setAutoUnregisterWhenFinished(true);
blinkerModifier = new LoopEntityModifier(sequenceModifier);
blinkerButtonSprite.registerEntityModifier(blinkerModifier);
}
public void disablePulsing() {
if (blinkerModifier != null) {
blinkerButtonSprite.unregisterEntityModifier(blinkerModifier);
blinkerModifier = null;
}
blinkerButtonSprite.setAlpha(0);
}
public boolean isEnbleda() { public boolean isEnbleda() {
return enabled; return enabled;
} }
......
...@@ -84,6 +84,7 @@ public class ResourceManager { ...@@ -84,6 +84,7 @@ public class ResourceManager {
public static final String CONTROL_NEXT = ASSET_CONTROL + "next.png"; public static final String CONTROL_NEXT = ASSET_CONTROL + "next.png";
public static final String CONTROL_START_UNPRESSED = ASSET_CONTROL + "start_button_unpressed.png"; public static final String CONTROL_START_UNPRESSED = ASSET_CONTROL + "start_button_unpressed.png";
public static final String CONTROL_START_DISABLED = ASSET_CONTROL + "start_button_disabled.png"; public static final String CONTROL_START_DISABLED = ASSET_CONTROL + "start_button_disabled.png";
public static final String CONTROL_START_BLINKER = ASSET_CONTROL + "start_button_blinker.png";
public static final String CONTROL_ACTUAL = ASSET_CONTROL + "actual.png"; public static final String CONTROL_ACTUAL = ASSET_CONTROL + "actual.png";
public static final String CONTROL_KEY = ASSET_CONTROL + "key_icon.png"; public static final String CONTROL_KEY = ASSET_CONTROL + "key_icon.png";
...@@ -103,6 +104,7 @@ public class ResourceManager { ...@@ -103,6 +104,7 @@ public class ResourceManager {
public static final String INFO_SAFE1 = ASSET_INFO + "safe1.png"; public static final String INFO_SAFE1 = ASSET_INFO + "safe1.png";
public static final String INFO_SAFE2 = ASSET_INFO + "safe2.png"; public static final String INFO_SAFE2 = ASSET_INFO + "safe2.png";
public static final String INFO_START_ARROW = ASSET_INFO + "start_arrow.png"; public static final String INFO_START_ARROW = ASSET_INFO + "start_arrow.png";
public static final String INFO_START_ARROW_BLINKER = ASSET_INFO + "start_arrow_blinker.png";
private static final String ASSET_SFX_SOURCE = ASSET_GAME + "sfx/"; private static final String ASSET_SFX_SOURCE = ASSET_GAME + "sfx/";
...@@ -205,6 +207,7 @@ public class ResourceManager { ...@@ -205,6 +207,7 @@ public class ResourceManager {
loadTexture(engine, context, CONTROL_NEXT); loadTexture(engine, context, CONTROL_NEXT);
loadTexture(engine, context, CONTROL_START_UNPRESSED); loadTexture(engine, context, CONTROL_START_UNPRESSED);
loadTexture(engine, context, CONTROL_START_DISABLED); loadTexture(engine, context, CONTROL_START_DISABLED);
loadTexture(engine, context, CONTROL_START_BLINKER);
loadTexture(engine, context, CONTROL_ACTUAL); loadTexture(engine, context, CONTROL_ACTUAL);
loadTexture(engine, context, CONTROL_KEY); loadTexture(engine, context, CONTROL_KEY);
...@@ -221,6 +224,7 @@ public class ResourceManager { ...@@ -221,6 +224,7 @@ public class ResourceManager {
loadTexture(engine, context, INFO_SAFE1); loadTexture(engine, context, INFO_SAFE1);
loadTexture(engine, context, INFO_SAFE2); loadTexture(engine, context, INFO_SAFE2);
loadTexture(engine, context, INFO_START_ARROW); loadTexture(engine, context, INFO_START_ARROW);
loadTexture(engine, context, INFO_START_ARROW_BLINKER);
SoundFactory.setAssetBasePath(ASSET_SFX_SOURCE); SoundFactory.setAssetBasePath(ASSET_SFX_SOURCE);
......
...@@ -24,14 +24,21 @@ import java.util.List; ...@@ -24,14 +24,21 @@ import java.util.List;
import org.andengine.entity.Entity; import org.andengine.entity.Entity;
import org.andengine.entity.IEntity; import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.DelayModifier;
import org.andengine.entity.modifier.FadeInModifier;
import org.andengine.entity.modifier.FadeOutModifier;
import org.andengine.entity.modifier.LoopEntityModifier;
import org.andengine.entity.modifier.SequenceEntityModifier;
import org.andengine.entity.primitive.Rectangle; import org.andengine.entity.primitive.Rectangle;
import org.andengine.entity.scene.Scene; import org.andengine.entity.scene.Scene;
import org.andengine.entity.sprite.Sprite; import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITextureRegion; import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager; import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.adt.color.Color; import org.andengine.util.adt.color.Color;
import org.andengine.util.modifier.IModifier;
import android.os.Handler; import android.os.Handler;
import cz.nic.tablexia.game.common.EntityModifierListenerAdapter;
import cz.nic.tablexia.game.games.potme.PotmeActivity; import cz.nic.tablexia.game.games.potme.PotmeActivity;
import cz.nic.tablexia.game.games.potme.PotmeActivity.StartButton; import cz.nic.tablexia.game.games.potme.PotmeActivity.StartButton;
import cz.nic.tablexia.game.games.potme.PotmeDifficulty; import cz.nic.tablexia.game.games.potme.PotmeDifficulty;
...@@ -83,16 +90,20 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -83,16 +90,20 @@ public class ActionsWidget extends Entity implements ActionListener {
} }
} }
private static final int TOP_Z_INDEX = ActionType.values().length + 1; private static final float TUTORIAL_INFO_ARROW_BLINK_DURATION = 1f;
private static final float BACKGROUND_WIDTH_RATIO = 1.3f; private static final float TUTORIAL_INFO_ARROW_FADEIN_DELAY = 0.5f;
private static final double BACKGROUND_Y_POSITION_RATIO = 0.9; private static final int TOP_Z_INDEX = ActionType.values().length + 1;
private static final int START_ANIMATION_DELAY = 200; private static final float BACKGROUND_WIDTH_RATIO = 1.3f;
private static final int NUMBER_OF_COLUMNS = 2; private static final double BACKGROUND_Y_POSITION_RATIO = 0.9;
public static final int ACTION_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 10; private static final int START_ANIMATION_DELAY = 200;
private static final float DIMMER_ALPHA = 0.5f; private static final int NUMBER_OF_COLUMNS = 2;
private static final Color DIMMER_COLOR = Color.BLACK; public static final int ACTION_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 10;
private static final float START_ARROW_WIDTH = PotmeActivity.TILE_SIZE * 1.2f; private static final float DIMMER_ALPHA = 0.5f;
private static final float START_ARROW_HEIGHT = PotmeActivity.TILE_SIZE; private static final Color DIMMER_COLOR = Color.BLACK;
private static final float START_ARROW_X_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER * 1.3f;
private static final int START_ARROW_Y_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 2;
private static final float START_ARROW_WIDTH = PotmeActivity.TILE_SIZE * 1.5f;
private static final float START_ARROW_HEIGHT = PotmeActivity.TILE_SIZE;
private ActionsStripWidget actionsStripWidget; private ActionsStripWidget actionsStripWidget;
private List<Action> actions; private List<Action> actions;
...@@ -153,8 +164,7 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -153,8 +164,7 @@ public class ActionsWidget extends Entity implements ActionListener {
} }
ActionLayer.ACTIONS_LAYER.getLayerEntity().attachChild(dimmer); ActionLayer.ACTIONS_LAYER.getLayerEntity().attachChild(dimmer);
ActionLayer.BACKGROUND_LAYER.getLayerEntity().attachChild(actionsBackground); ActionLayer.BACKGROUND_LAYER.getLayerEntity().attachChild(actionsBackground);
tryDimmAllActions();
tryToPerformNextTutorialStep();
} }
public void setStartButton(StartButton startButton) { public void setStartButton(StartButton startButton) {
...@@ -201,13 +211,21 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -201,13 +211,21 @@ public class ActionsWidget extends Entity implements ActionListener {
}, actualDelay); }, actualDelay);
actualDelay = actualDelay + START_ANIMATION_DELAY; actualDelay = actualDelay + START_ANIMATION_DELAY;
} }
(new Handler()).postDelayed(new Runnable() {
@Override
public void run() {
tryToPerformNextTutorialStep();
}
}, actualDelay + START_ANIMATION_DELAY);
} }
/* //////////////////////////////////////////// ACTION STATE */ /* //////////////////////////////////////////// ACTION STATE */
public void enableActions() { public void enableActions() {
if (potmeDifficulty != PotmeDifficulty.TUTORIAL) { if (potmeDifficulty != PotmeDifficulty.TUTORIAL) {
for (Action action : actions) { for (Action action : actions) {
action.enable(); action.enable();
} }
...@@ -251,13 +269,11 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -251,13 +269,11 @@ public class ActionsWidget extends Entity implements ActionListener {
if (potmeDifficulty == PotmeDifficulty.TUTORIAL) { if (potmeDifficulty == PotmeDifficulty.TUTORIAL) {
if (currentStepNumber < PotmeActivity.TUTORIAL_STEPS.size()) { if (currentStepNumber < PotmeActivity.TUTORIAL_STEPS.size()) {
highliteAction(PotmeActivity.TUTORIAL_STEPS.get(currentStepNumber)); highliteAction(PotmeActivity.TUTORIAL_STEPS.get(currentStepNumber));
if (startButton != null) {
startButton.disable();
}
} else { } else {
PotmeActivity.GameLayer.BUTTON_LAYER.sendToFront(scene); PotmeActivity.GameLayer.BUTTON_LAYER.sendToFront(scene);
if (startButton != null) { if (startButton != null) {
startButton.enable(); startButton.enable();
startButton.enablePulsing();
} }
} }
} else { } else {
...@@ -265,19 +281,21 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -265,19 +281,21 @@ public class ActionsWidget extends Entity implements ActionListener {
} }
} }
private void dimmAllActions() { private void tryDimmAllActions() {
dimmer.setVisible(true); if (potmeDifficulty == PotmeDifficulty.TUTORIAL) {
for (Action action : actions) { dimmer.setVisible(true);
action.setZIndex(action.getOrderNumber()); for (Action action : actions) {
action.disable(); action.setZIndex(action.getOrderNumber());
action.disable();
}
dimmer.setZIndex(actions.size());
ActionLayer.ACTIONS_LAYER.getLayerEntity().sortChildren();
} }
dimmer.setZIndex(actions.size());
ActionLayer.ACTIONS_LAYER.getLayerEntity().sortChildren();
} }
private void highliteAction(ActionType actionType) { private void highliteAction(ActionType actionType) {
if (actionType.ordinal() < actions.size()) { if (actionType.ordinal() < actions.size()) {
dimmAllActions(); tryDimmAllActions();
Action action = actions.get(actionType.ordinal()); Action action = actions.get(actionType.ordinal());
action.setZIndex(TOP_Z_INDEX); action.setZIndex(TOP_Z_INDEX);
action.enable(); action.enable();
...@@ -288,13 +306,46 @@ public class ActionsWidget extends Entity implements ActionListener { ...@@ -288,13 +306,46 @@ public class ActionsWidget extends Entity implements ActionListener {
private void showArrowSprite(float positionX, float positionY, VertexBufferObjectManager vertexBufferObjectManager) { private void showArrowSprite(float positionX, float positionY, VertexBufferObjectManager vertexBufferObjectManager) {
hideArrowSprite(); hideArrowSprite();
Sprite infoArrowSprite = new Sprite(positionX + (PotmeActivity.ACTION_SIZE_SMALLER * 1.2f), final Sprite infoArrowSprite = new Sprite(positionX + START_ARROW_X_OFFSET,
positionY - (PotmeActivity.ACTION_SIZE_SMALLER / 2), positionY - START_ARROW_Y_OFFSET,
START_ARROW_WIDTH, START_ARROW_WIDTH,
START_ARROW_HEIGHT, START_ARROW_HEIGHT,
ResourceManager.getInstance().getTexture(ResourceManager.INFO_START_ARROW), ResourceManager.getInstance().getTexture(ResourceManager.INFO_START_ARROW),
vertexBufferObjectManager); vertexBufferObjectManager);
final Sprite infoArrowBlinkerSprite = new Sprite(positionX + START_ARROW_X_OFFSET,
positionY - START_ARROW_Y_OFFSET,
START_ARROW_WIDTH,
START_ARROW_HEIGHT,
ResourceManager.getInstance().getTexture(ResourceManager.INFO_START_ARROW_BLINKER),
vertexBufferObjectManager);
infoArrowSprite.setAlpha(0);
infoArrowBlinkerSprite.setAlpha(0);
ActionLayer.INFO_LAYER.getLayerEntity().attachChild(infoArrowSprite); ActionLayer.INFO_LAYER.getLayerEntity().attachChild(infoArrowSprite);
ActionLayer.INFO_LAYER.getLayerEntity().attachChild(infoArrowBlinkerSprite);
FadeInModifier fadeIn = new FadeInModifier(TUTORIAL_INFO_ARROW_BLINK_DURATION);
fadeIn.setAutoUnregisterWhenFinished(true);
FadeOutModifier fadeOut = new FadeOutModifier(TUTORIAL_INFO_ARROW_BLINK_DURATION);
fadeOut.setAutoUnregisterWhenFinished(true);
final SequenceEntityModifier sequenceModifier = new SequenceEntityModifier(fadeIn, fadeOut);
sequenceModifier.setAutoUnregisterWhenFinished(true);
DelayModifier delayModifier = new DelayModifier(TUTORIAL_INFO_ARROW_FADEIN_DELAY);
delayModifier.setAutoUnregisterWhenFinished(true);
delayModifier.addModifierListener(new EntityModifierListenerAdapter() {
@Override
public void onModifierFinished(IModifier<IEntity> pModifier, IEntity pItem) {
FadeInModifier fadeInModifier = new FadeInModifier(TUTORIAL_INFO_ARROW_FADEIN_DELAY);
fadeInModifier.setAutoUnregisterWhenFinished(true);
infoArrowSprite.registerEntityModifier(fadeInModifier);
infoArrowBlinkerSprite.registerEntityModifier(new LoopEntityModifier(sequenceModifier));
}
});
infoArrowSprite.registerEntityModifier(delayModifier);
} }
private void hideArrowSprite() { private void hideArrowSprite() {
......
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