mwg API
    Preparing search index...

    Class Viewport

    One player's own rectangle of the screen, for a same-screen local multiplayer layout: a Camera whose world is offset to start at x/y instead of the corner of the canvas, and clipped to width/height so it never bleeds into a neighbouring player's share of the screen. A game with a single Viewport covering the whole canvas behaves exactly like a game using a bare Camera directly - this adds a screen region and a mask around it, nothing else.

    import { Viewport, splitScreenHalves } from '@datamoc/mw_games/two-d/render';

    const [left, right] = splitScreenHalves(640, 360);
    const player1 = new Viewport({ ...left, zoom: 2 });
    const player2 = new Viewport({ ...right, zoom: 2 });
    // add both containers: game.stage.addChild(player1.container, player2.container);

    player1.camera.follow({ x: 50, y: 50 });
    player1.update(1 / 60);
    Index
    camera: Camera
    container: Container<ContainerChild> = ...

    add this to Game.current.stage, the way a single-camera game already adds camera.world

    • moves and/or resizes this viewport's own rectangle of the screen

      Parameters

      • x: number
      • y: number
      • width: number
      • height: number

      Returns void