use of com.agorria.shootandmove.menu.MenuEnding in project ShootAndRun by IonAgorria.
the class GameUI method sizeChanged.
/**
* Called when size of view is changed
*
* @param width in pixes
* @param height in pixels
*/
public void sizeChanged(GameView view, int width, int height) {
Log.d(TAG, "sizeChanged " + width + "x" + height);
this.viewWidth = width == 0 ? 1 : width;
this.viewHeight = height == 0 ? 1 : height;
this.aspect = viewWidth / viewHeight;
// Create non scaled background and submit
TextureAtlas sprite128 = view.getTextureAtlas(TextureAtlas.Atlas.Sprite128);
List<Drawable> backgrounds = new ArrayList<>();
backgrounds.add(new DrawableRectangle(aspect / 2f - 1f, 0, 1f, 1f, sprite128.getRegion(0, 0).copy().flip(false, true)));
backgrounds.add(new DrawableRectangle(aspect / 2f, 0, 1f, 1f, sprite128.getRegion(0, 0)));
DrawableBatch batch = view.createBatchOrthographic(DrawableBatch.SLOT.Background, backgrounds, Color.WHITE);
view.submitBatch(batch);
// Generate menus
menuMap.put(MenuMain.class, new MenuMain(this, view));
menuMap.put(MenuHelp.class, new MenuHelp(this, view));
menuMap.put(MenuPlay.class, new MenuPlay(this, view));
menuMap.put(MenuIntro.class, new MenuIntro(this, view));
menuMap.put(MenuEnding.class, new MenuEnding(this, view));
menuMap.put(MenuCredits.class, new MenuCredits(this, view));
menuMap.put(MenuOptions.class, new MenuOptions(this, view));
// Generate control drawables
TextureAtlas atlas = view.getTextureAtlas(TextureAtlas.Atlas.Sprite32);
gameDrawables.clear();
float controlSize = CONTROLS_SIZE / 2;
// Joystick
joystickRectangle = new Rectangle(CONTROLS_PADDING, CONTROLS_PADDING, controlSize * 2, controlSize * 2);
gameDrawables.add(new DrawableRectangle(joystickRectangle, atlas.getRegion(14, 0)));
// Shoot
gameDrawables.add(new DrawableRectangle(aspect - controlSize - CONTROLS_PADDING, CONTROLS_PADDING + controlSize, controlSize, controlSize, atlas.getRegion(14, 1)));
// Prev
gameDrawables.add(new DrawableRectangle(aspect - controlSize * 2 - CONTROLS_PADDING, CONTROLS_PADDING, controlSize, controlSize, atlas.getRegion(15, 0)));
// Next
gameDrawables.add(new DrawableRectangle(aspect - controlSize - CONTROLS_PADDING, CONTROLS_PADDING, controlSize, controlSize, // Flip side
atlas.getRegion(15, 0).copy().flip(true, false)));
// Cross
gameDrawables.add(new DrawableRectangle(aspect / 2f - CROSS_SIZE / 2f, 0.5f - CROSS_SIZE / 2f, CROSS_SIZE, CROSS_SIZE, atlas.getRegion(8, 1)));
// Health
float playerSpace = aspect * PLAYER_SPACE;
float playerPadding = (1f - PLAYER_PADDING) - PLAYER_SIZE;
gameDrawables.add(new DrawableRectangle(aspect / 2 - playerSpace - PLAYER_SIZE, playerPadding, PLAYER_SIZE, PLAYER_SIZE, atlas.getRegion(4, 2).copy().setSizeCentered(20, 20)));
// Movement
movementDrawables = new Drawable[] { new DrawableRectangle(aspect - controlSize * 2 - CONTROLS_PADDING, CONTROLS_PADDING + controlSize, controlSize, controlSize, atlas.getRegion(15, 1)), new DrawableRectangle(aspect - controlSize * 2 - CONTROLS_PADDING, CONTROLS_PADDING + controlSize, controlSize, controlSize, atlas.getRegion(15, 2)) };
// Death drawables
deathDrawables = new Drawable[] { new DrawableRectangle(0, 0, aspect, 1f, atlas.getRegion(14, 2)), new DrawableRectangle(0, 0, aspect, 1f, atlas.getRegion(13, 2)), new DrawableRectangle(0, 0, aspect, 1f, atlas.getRegion(12, 2)) };
// Set flag
requireDraw = true;
}
Aggregations