excaliburjs / Excalibur

🎮 Your friendly TypeScript 2D game engine for the web 🗡️
https://excaliburjs.com
BSD 2-Clause "Simplified" License
1.82k stars 188 forks source link

Allow scaling drawable object by absolute resolution #1527

Closed DaVince closed 2 years ago

DaVince commented 4 years ago

Context

Drawable objects (like actors) can be scaled by a ratio, but not by an exact pixel value. In some cases, I'd like to be able to set the size of an actor to something very specific (like the size of the game screen).

Proposal

It would be nice if we could not just read, but also set the drawWidth and drawHeight properties. Excalibur should scale the graphical content appropriately.

github-actions[bot] commented 3 years ago

This issue hasn't had any recent activity lately and is being marked as stale automatically.

eonarheim commented 2 years ago

@DaVince we added some more Screen api's to adjust the viewport/resolution of the graphics dynamically. Does that provide what you were looking for?

https://excaliburjs.com/docs/screens#advanced-viewport-and-resolution-manipulation

Screen also supports getting the current resolution width/height

const game = new ex.Engine({...});

await game.start();

const actor = new ex.Actor({
    x: 0,
    y: 0,
    width: game.screen.resolution.width,
    height: game.screen.resolution.height,
    color: ex.Color.Blue
  });

actor.graphics.anchor = ex.Vector.Zero;

game.add(actor);
eonarheim commented 2 years ago

Doing some backlog cleanup, closing for now let me know if we need to re-open 👍