Search in sources :

Example 1 with MenuCredits

use of com.agorria.shootandmove.menu.MenuCredits 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;
}
Also used : DrawableRectangle(com.agorria.shootandmove.graphics.DrawableRectangle) MenuMain(com.agorria.shootandmove.menu.MenuMain) MenuCredits(com.agorria.shootandmove.menu.MenuCredits) Drawable(com.agorria.shootandmove.graphics.Drawable) ArrayList(java.util.ArrayList) MenuPlay(com.agorria.shootandmove.menu.MenuPlay) DrawableRectangle(com.agorria.shootandmove.graphics.DrawableRectangle) Rectangle(com.agorria.shootandmove.math.Rectangle) MenuEnding(com.agorria.shootandmove.menu.MenuEnding) MenuOptions(com.agorria.shootandmove.menu.MenuOptions) MenuIntro(com.agorria.shootandmove.menu.MenuIntro) TextureAtlas(com.agorria.shootandmove.graphics.TextureAtlas) MenuHelp(com.agorria.shootandmove.menu.MenuHelp) DrawableBatch(com.agorria.shootandmove.graphics.DrawableBatch)

Aggregations

Drawable (com.agorria.shootandmove.graphics.Drawable)1 DrawableBatch (com.agorria.shootandmove.graphics.DrawableBatch)1 DrawableRectangle (com.agorria.shootandmove.graphics.DrawableRectangle)1 TextureAtlas (com.agorria.shootandmove.graphics.TextureAtlas)1 Rectangle (com.agorria.shootandmove.math.Rectangle)1 MenuCredits (com.agorria.shootandmove.menu.MenuCredits)1 MenuEnding (com.agorria.shootandmove.menu.MenuEnding)1 MenuHelp (com.agorria.shootandmove.menu.MenuHelp)1 MenuIntro (com.agorria.shootandmove.menu.MenuIntro)1 MenuMain (com.agorria.shootandmove.menu.MenuMain)1 MenuOptions (com.agorria.shootandmove.menu.MenuOptions)1 MenuPlay (com.agorria.shootandmove.menu.MenuPlay)1 ArrayList (java.util.ArrayList)1