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;
import org.andengine.entity.IEntity;
import org.andengine.entity.modifier.AlphaModifier;
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.SequenceEntityModifier;
import org.andengine.entity.primitive.Rectangle;
import org.andengine.entity.scene.Scene;
import org.andengine.entity.scene.background.Background;
......@@ -213,6 +217,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private boolean enabled = true;
private Entity backgroundLayer;
private Entity blinkerLayer;
private Entity textLayer;
private Rectangle touchArea;
......@@ -221,6 +226,7 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private Sprite unpressedButtonSprite;
private Sprite disabledButtonSprite;
private Sprite blinkerButtonSprite;
private Text buttonText;
private float textUnpressedPositionX;
......@@ -228,17 +234,25 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
private float textPressedPositionX;
private float textPressedPositionY;
private LoopEntityModifier blinkerModifier;
public StartButton(VertexBufferObjectManager vertexBufferObject) {
// layers
backgroundLayer = new Entity();
blinkerLayer = new Entity();
textLayer = new Entity();
attachChild(backgroundLayer);
attachChild(blinkerLayer);
attachChild(textLayer);
// backgrounds
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);
blinkerButtonSprite = new Sprite(0, 0, ResourceManager.getInstance().getTexture(ResourceManager.CONTROL_START_BLINKER), vertexBufferObject);
disablePulsing();
blinkerLayer.attachChild(blinkerButtonSprite);
// touch area
touchArea = new Rectangle(0, 0, unpressedButtonSprite.getWidth(), unpressedButtonSprite.getHeight(), vertexBufferObject) {
......@@ -273,11 +287,31 @@ public class PotmeActivity extends GameActivity implements TileMapClickListener
}
public void disable() {
disablePulsing();
enabled = false;
changeActualButtonSprite(disabledButtonSprite);
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() {
return enabled;
}
......
......@@ -84,6 +84,7 @@ public class ResourceManager {
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_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_KEY = ASSET_CONTROL + "key_icon.png";
......@@ -103,6 +104,7 @@ public class ResourceManager {
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_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/";
......@@ -205,6 +207,7 @@ public class ResourceManager {
loadTexture(engine, context, CONTROL_NEXT);
loadTexture(engine, context, CONTROL_START_UNPRESSED);
loadTexture(engine, context, CONTROL_START_DISABLED);
loadTexture(engine, context, CONTROL_START_BLINKER);
loadTexture(engine, context, CONTROL_ACTUAL);
loadTexture(engine, context, CONTROL_KEY);
......@@ -221,6 +224,7 @@ public class ResourceManager {
loadTexture(engine, context, INFO_SAFE1);
loadTexture(engine, context, INFO_SAFE2);
loadTexture(engine, context, INFO_START_ARROW);
loadTexture(engine, context, INFO_START_ARROW_BLINKER);
SoundFactory.setAssetBasePath(ASSET_SFX_SOURCE);
......
......@@ -24,14 +24,21 @@ import java.util.List;
import org.andengine.entity.Entity;
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.scene.Scene;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.texture.region.ITextureRegion;
import org.andengine.opengl.vbo.VertexBufferObjectManager;
import org.andengine.util.adt.color.Color;
import org.andengine.util.modifier.IModifier;
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.StartButton;
import cz.nic.tablexia.game.games.potme.PotmeDifficulty;
......@@ -83,6 +90,8 @@ public class ActionsWidget extends Entity implements ActionListener {
}
}
private static final float TUTORIAL_INFO_ARROW_BLINK_DURATION = 1f;
private static final float TUTORIAL_INFO_ARROW_FADEIN_DELAY = 0.5f;
private static final int TOP_Z_INDEX = ActionType.values().length + 1;
private static final float BACKGROUND_WIDTH_RATIO = 1.3f;
private static final double BACKGROUND_Y_POSITION_RATIO = 0.9;
......@@ -91,7 +100,9 @@ public class ActionsWidget extends Entity implements ActionListener {
public static final int ACTION_OFFSET = PotmeActivity.ACTION_SIZE_SMALLER / 10;
private static final float DIMMER_ALPHA = 0.5f;
private static final Color DIMMER_COLOR = Color.BLACK;
private static final float START_ARROW_WIDTH = PotmeActivity.TILE_SIZE * 1.2f;
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;
......@@ -153,8 +164,7 @@ public class ActionsWidget extends Entity implements ActionListener {
}
ActionLayer.ACTIONS_LAYER.getLayerEntity().attachChild(dimmer);
ActionLayer.BACKGROUND_LAYER.getLayerEntity().attachChild(actionsBackground);
tryToPerformNextTutorialStep();
tryDimmAllActions();
}
public void setStartButton(StartButton startButton) {
......@@ -201,6 +211,14 @@ public class ActionsWidget extends Entity implements ActionListener {
}, actualDelay);
actualDelay = actualDelay + START_ANIMATION_DELAY;
}
(new Handler()).postDelayed(new Runnable() {
@Override
public void run() {
tryToPerformNextTutorialStep();
}
}, actualDelay + START_ANIMATION_DELAY);
}
......@@ -251,13 +269,11 @@ public class ActionsWidget extends Entity implements ActionListener {
if (potmeDifficulty == PotmeDifficulty.TUTORIAL) {
if (currentStepNumber < PotmeActivity.TUTORIAL_STEPS.size()) {
highliteAction(PotmeActivity.TUTORIAL_STEPS.get(currentStepNumber));
if (startButton != null) {
startButton.disable();
}
} else {
PotmeActivity.GameLayer.BUTTON_LAYER.sendToFront(scene);
if (startButton != null) {
startButton.enable();
startButton.enablePulsing();
}
}
} else {
......@@ -265,7 +281,8 @@ public class ActionsWidget extends Entity implements ActionListener {
}
}
private void dimmAllActions() {
private void tryDimmAllActions() {
if (potmeDifficulty == PotmeDifficulty.TUTORIAL) {
dimmer.setVisible(true);
for (Action action : actions) {
action.setZIndex(action.getOrderNumber());
......@@ -274,10 +291,11 @@ public class ActionsWidget extends Entity implements ActionListener {
dimmer.setZIndex(actions.size());
ActionLayer.ACTIONS_LAYER.getLayerEntity().sortChildren();
}
}
private void highliteAction(ActionType actionType) {
if (actionType.ordinal() < actions.size()) {
dimmAllActions();
tryDimmAllActions();
Action action = actions.get(actionType.ordinal());
action.setZIndex(TOP_Z_INDEX);
action.enable();
......@@ -288,13 +306,46 @@ public class ActionsWidget extends Entity implements ActionListener {
private void showArrowSprite(float positionX, float positionY, VertexBufferObjectManager vertexBufferObjectManager) {
hideArrowSprite();
Sprite infoArrowSprite = new Sprite(positionX + (PotmeActivity.ACTION_SIZE_SMALLER * 1.2f),
positionY - (PotmeActivity.ACTION_SIZE_SMALLER / 2),
final Sprite infoArrowSprite = 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),
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(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() {
......
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