Skip to content
Snippets Groups Projects
Commit 88f148d5 authored by Luboš Horáček's avatar Luboš Horáček
Browse files

#31 Scene layout

parent 2eed3ffe
No related branches found
No related tags found
No related merge requests found
Showing
with 94 additions and 23 deletions
......@@ -12,6 +12,7 @@ import cz.nic.tablexia.bus.event.LocaleChangedEvent;
import cz.nic.tablexia.game.GameDefinition;
import cz.nic.tablexia.game.difficulty.GameDifficulty;
import cz.nic.tablexia.game.games.kidnapping.KidnappingGame;
import cz.nic.tablexia.game.games.shooting_range.ShootingRangeGame;
import cz.nic.tablexia.loader.application.ApplicationTextManager;
import cz.nic.tablexia.screen.AbstractTablexiaScreen;
import cz.nic.tablexia.util.Log;
......@@ -24,7 +25,7 @@ public class TablexiaSettings {
private static final int MIN_SCREEN_HEIGHT = (int) (DEFAULT_SCREEN_WIDTH * MAXIMUM_RATIO);
private static final boolean DEBUG_SHOW_BOUNDING_BOXES = true;
public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = KidnappingGame.class;
public static final Class<? extends AbstractTablexiaScreen<?>> INITIAL_SCREEN = ShootingRangeGame.class;
public static final int AVATAR_COUNT = 8;
private static final String PREFERENCES_KEY = "cz.nic.tablexia.";
......
......@@ -60,11 +60,11 @@ public class KidnappingGame extends AbstractTablexiaGame<GameState> {
@Override
protected void gameLoaded() {
getStage().setDebugAll(TablexiaSettings.getInstance().isShowBoundingBoxes());
super.gameLoaded();
// TODO show rule screen
// TODO show sub-rule screen
getStage().setDebugAll(TablexiaSettings.getInstance().isShowBoundingBoxes());
getStage().addActor(map = Map.MapFactory.createInstance(this, gfxLibrary, getData()));
map.setBounds(0, getStage().getCamera().position.y - getStage().getHeight() / 2, getStage().getWidth(), getStage().getHeight()); // scaling viewport camera y-position adjustment
map.setMapScale(0.5f);
......
package cz.nic.tablexia.game.games.shooting_range;
import com.badlogic.gdx.scenes.scene2d.Actor;
import java.util.List;
import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.game.AbstractTablexiaGame;
import cz.nic.tablexia.game.games.shooting_range.actors.Scene;
import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.common.media.SfxLibrary;
import cz.nic.tablexia.game.games.shooting_range.actors.Scene;
import cz.nic.tablexia.game.games.shooting_range.media.SoundType;
import cz.nic.tablexia.game.games.shooting_range.media.Textures;
import cz.nic.tablexia.game.games.shooting_range.model.GameState;
......@@ -20,12 +19,7 @@ public class ShootingRangeGame extends AbstractTablexiaGame<GameState> {
private GfxLibrary gfxLibrary = new GfxLibrary(this, Textures.values());
private SfxLibrary sfxLibrary = new SfxLibrary(this, SoundType.values());
private Actor watch;
private Actor watchHand;
private Actor carousel;
private Actor scoreText;
Scene scene;
private Scene scene;
@Override
protected void prepareScreenSoundAssetNames(List<String> soundsFileNames) {
......@@ -42,6 +36,7 @@ public class ShootingRangeGame extends AbstractTablexiaGame<GameState> {
@Override
protected void gameLoaded() {
getStage().setDebugAll(TablexiaSettings.getInstance().isShowBoundingBoxes());
super.gameLoaded();
initScene();
......@@ -49,10 +44,9 @@ public class ShootingRangeGame extends AbstractTablexiaGame<GameState> {
}
private void initScene() {
getStage().addActor(scene = new Scene(gfxLibrary));
scene.setBounds(0, getStage().getCamera().position.y - getStage().getHeight() / 2, getStage().getWidth(), getStage().getHeight()); // scaling viewport camera y-position adjustment
// TODO prepare scene
// TODO prepare carousel
// TODO prepare stopwatch
// TODO
}
}
package cz.nic.tablexia.game.games.shooting_range.actors;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.games.shooting_range.media.Textures;
/**
* Created by lhoracek on 6/23/15.
*/
public class Carousel extends Group {
private Image carouselBase;
public Carousel(GfxLibrary gfxLibrary) {
addActor(carouselBase = new Image(gfxLibrary.getTextureRegion(Textures.CAROUSEL)));
setSize(carouselBase.getWidth(), carouselBase.getHeight());
}
}
package cz.nic.tablexia.game.games.shooting_range.actors;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.games.shooting_range.media.Textures;
/**
* Created by lhoracek on 6/23/15.
*/
public class Row {
public class Row extends Group {
private Image wave;
public Row(GfxLibrary gfxLibrary, Textures texture) {
addActor(wave = new Image(gfxLibrary.getTextureRegion(texture)));
}
@Override
protected void sizeChanged() {
super.sizeChanged();
wave.setSize(getWidth(), getHeight());
}
}
package cz.nic.tablexia.game.games.shooting_range.actors;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import com.badlogic.gdx.scenes.scene2d.ui.Stack;
import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.games.shooting_range.media.Textures;
......@@ -9,12 +9,45 @@ import cz.nic.tablexia.game.games.shooting_range.media.Textures;
/**
* Created by lhoracek on 6/23/15.
*/
public class Scene extends Stack {
public class Scene extends Group {
private final Image frame;
private final Image background;
private Row row1, row2, row3;
private final Carousel carousel;
private final Watch watch;
public Scene(GfxLibrary gfxLibrary) {
add(background = new Image(gfxLibrary.getTextureRegion(Textures.BACKGROUND)));
add(frame = new Image(gfxLibrary.getTextureRegion(Textures.FRAME)));
addActor(background = new Image(gfxLibrary.getTextureRegion(Textures.BACKGROUND)));
addActor(row1 = new Row(gfxLibrary, Textures.WAVE_1));
addActor(row2 = new Row(gfxLibrary, Textures.WAVE_2));
addActor(row3 = new Row(gfxLibrary, Textures.WAVE_3));
addActor(frame = new Image(gfxLibrary.getTextureRegion(Textures.FRAME)));
addActor(watch = new Watch(gfxLibrary));
watch.setScale(0.5f);
addActor(carousel = new Carousel(gfxLibrary));
carousel.setScale(0.5f);
}
@Override
protected void sizeChanged() {
super.sizeChanged();
background.setSize(getWidth(), getHeight());
frame.setSize(getWidth(), getHeight());
row1.setSize(getWidth(), getHeight()/5*3);
row2.setSize(getWidth(), getHeight()/5*2);
row3.setSize(getWidth(), getHeight()/5*1);
carousel.setPosition(getWidth() - (carousel.getWidth() * carousel.getScaleX() / 9 * 5), getHeight() - (carousel.getHeight() * carousel.getScaleY() / 9 * 5));
}
public Carousel getCarousel() {
return carousel;
}
public Watch getWatch() {
return watch;
}
}
package cz.nic.tablexia.game.games.shooting_range.actors;
import com.badlogic.gdx.scenes.scene2d.Group;
import com.badlogic.gdx.scenes.scene2d.actions.Actions;
import com.badlogic.gdx.scenes.scene2d.ui.Image;
import cz.nic.tablexia.game.common.media.GfxLibrary;
import cz.nic.tablexia.game.games.shooting_range.media.Textures;
/**
* Created by lhoracek on 6/23/15.
*/
public class Watch extends Group{
private Image watch, watchHand;
public Watch(GfxLibrary gfxLibrary) {
addActor(watch = new Image(gfxLibrary.getTextureRegion(Textures.WATCH)));
addActor(watchHand = new Image(gfxLibrary.getTextureRegion(Textures.WATCH_HAND)));
watchHand.setPosition(254, 166);
watchHand.setOrigin(watchHand.getWidth()/2, 15);
watchHand.addAction(Actions.forever(Actions.rotateBy(-360,2)));
}
}
......@@ -18,9 +18,9 @@ public enum Textures implements AssetDescription {
BOX_BAD("box_bad"), //
BOX_GOOD("box_good"), //
WAVE_1("plan_2"), //
WAVE_2("plan_1"), //
WAVE_3("plan_3"), //
WAVE_1("plan2"), //
WAVE_2("plan1"), //
WAVE_3("plan3"), //
FLOWER_1("flowers/1"), //
FLOWER_2("flowers/2"), //
......
......@@ -62,7 +62,7 @@ public class DragActorListener extends InputListener {
float bx = actor.getX() + (x - grabX) * actor.getScaleX();
float by = actor.getY() + (y - grabY) * actor.getScaleY();
actor.setPosition(bx, by);
if (actor.getDebug() && logging) {
if (actor.getDebug()) { // TODO enable logging switch
Log.info(((Object) this).getClass().getName(), "Position " + bx + "x" + by);
}
event.stop();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment