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

#31 Scene actors positioning on resize

parent 88f148d5
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,9 @@ import cz.nic.tablexia.TablexiaSettings;
import cz.nic.tablexia.game.AbstractTablexiaGame;
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.Carousel;
import cz.nic.tablexia.game.games.shooting_range.actors.Scene;
import cz.nic.tablexia.game.games.shooting_range.actors.Watch;
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;
......@@ -19,7 +21,9 @@ public class ShootingRangeGame extends AbstractTablexiaGame<GameState> {
private GfxLibrary gfxLibrary = new GfxLibrary(this, Textures.values());
private SfxLibrary sfxLibrary = new SfxLibrary(this, SoundType.values());
private Scene scene;
private Scene scene;
private Carousel carousel;
private Watch watch;
@Override
protected void prepareScreenSoundAssetNames(List<String> soundsFileNames) {
......@@ -44,9 +48,19 @@ 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
getStage().addActor(watch = new Watch(gfxLibrary));
watch.setScale(0.5f);
getStage().addActor(carousel = new Carousel(gfxLibrary));
carousel.setScale(0.5f);
screenResized((int)getStage().getWidth(), (int)getStage().getHeight());
}
@Override
protected void screenResized(int width, int height) {
super.screenResized(width, height);
watch.setPosition(0, getStage().getCamera().position.y - getStage().getHeight() / 2);
carousel.setPosition(getStage().getWidth() - carousel.getWidth() /2 , getStage().getHeight() + (getStage().getCamera().position.y - getStage().getHeight() / 2));
}
}
......@@ -13,21 +13,14 @@ 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) {
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
......@@ -39,15 +32,5 @@ public class Scene extends Group {
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;
}
}
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