drawWidth and canvasWidth in FullScreen Mode

15 views
Skip to first unread message

Russel Villacarlos

unread,
Jun 7, 2018, 3:37:14 AM6/7/18
to excaliburjs
I am creating a full screen mode game and I added borders/walls surrounding the canvas. I decided to make the borders as actors so that I can set their collisionType and let the game engine handle the collision.

I set the width of the north border to be equal to the drawWidth of the engine and I am expecting that since it is in full screen mode, the north border will cover the entire width of the canvas. However, it turns out that the width is just half of the canvass. I want to know if this is really the behavior of the the drawWidth property in full screen mode.

Thanks.

Erik Onarheim

unread,
Jun 7, 2018, 8:34:23 AM6/7/18
to excaliburjs
Hi Russel,

Thanks for trying out excalibur and posting!

I think I know what the issue is, Actors by default have an anchor of (.5, .5) which centers there coordinates in the middle of their bounds. This causes the width to appear half (especially if placing the north wall at coordinate (0,0) )

I have a code pen here that hopefully demonstrates this, basically I've set the anchor of the actor to be (0, 0) which sets the actor's coordinates to be at the top-left of their bounds



let game = new ex.Engine({
  displayMode: ex.DisplayMode.FullScreen
});

game.isDebug = true;

let wall = new ex.Actor(0, 0, game.drawWidth, 50, ex.Color.Red);
wall.anchor = ex.Vector.Zero.clone();
game.add(wall);
game.start();



Let me know if I'm close to the issue you're after.

Cheers,
Erik

Russel Villacarlos

unread,
Jun 9, 2018, 12:29:18 PM6/9/18
to excaliburjs
Thanks for the reply. This solves the issue I'm having. I am used to having the handle at the top-left corner by default.Thanks again.

Kamran Ayub

unread,
Jun 9, 2018, 1:18:12 PM6/9/18
to Russel Villacarlos, excaliburjs
We added support for setting the anchor globally in the last release: 
https://github.com/excaliburjs/Excalibur/blob/master/CHANGELOG.md#added-1

You can set Actor.defaults.anchor to 0,0

On Sat, Jun 9, 2018, 11:29 Russel Villacarlos <russelvi...@gmail.com> wrote:
Thanks for the reply. This solves the issue I'm having. I am used to having the handle at the top-left corner by default.Thanks again.

--
You received this message because you are subscribed to the Google Groups "excaliburjs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to excaliburjs...@googlegroups.com.
To post to this group, send email to excal...@googlegroups.com.
Visit this group at https://groups.google.com/group/excaliburjs.
To view this discussion on the web visit https://groups.google.com/d/msgid/excaliburjs/3416c7a5-27a6-4ca6-a85d-a13df2827dd5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages