Game Resizing with fixed floor

25 views
Skip to first unread message

jtgbu...@gmail.com

unread,
Dec 1, 2018, 11:11:13 AM12/1/18
to excaliburjs
This is my first time using excalibur, and I am trying to make a side scroller. The problem is I cant seem to figure out how to make a fixed floor that will adjust on resizes. I started with https://github.com/excaliburjs/example-ts-webpack as my base and then added enabled physics and set a fixed acc y of 100 to simulate gravity. I made a floor with a fixed collision type but the problem is when you resize the screen it doesnt move. It also wouldnt become the full width of the screen on width resizes. I was able to fix the width by just adjusting the width on predraw if the canvas size has changed, but when I tried to apply the same to the y positing to make it stay fixed to the bottom it seems to act very weird and never actually stay at the bottom at resizes. Instead jumping above(higher then the screen size), and sometimes lower when going larger.

Example predraw code for floor,

public onPreDraw(ctx: CanvasRenderingContext2D) {
if (this.getWidth() !== this.scene.engine.canvasWidth) {
this.setWidth(this.scene.engine.canvasWidth);
}
if (this.getWorldPos().y !== this.scene.engine.drawHeight) {
this.y = this.scene.engine.drawHeight;
}
}
Reply all
Reply to author
Forward
0 new messages