Skip to content

Commit 851fc99

Browse files
authored
fix: [#3599] ScreenElement scale (#3615)
closes: #3599
1 parent 1be15c8 commit 851fc99

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
7474

7575
### Fixed
7676

77+
- Fixed issue where setting the width/height of a ScreenElement was incorrectly scaled when supplied with a scale in the ctor
7778
- Fixed issue where onRemove would sometimes not be called
7879
- Fixed issue where pointer containment WAS NOT being uses on collision shape geometry, only their bounds
7980
- Fixed issue where overriding built in uniforms and graphics no longer worked as v0.30.x

sandbox/src/game.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ var game = new ex.Engine({
4545
width: 800,
4646
height: 600,
4747
canvasElementId: 'game',
48-
suppressPlayButton: true,
48+
// suppressPlayButton: true,
4949
pointerScope: ex.PointerScope.Canvas,
5050
displayMode: ex.DisplayMode.FitScreenAndFill,
5151
snapToPixel: false,
@@ -204,6 +204,17 @@ cards2.draw(game.graphicsContext, 0, 0);
204204

205205
jump.volume = 0.3;
206206

207+
var screenBox = new ex.ScreenElement({
208+
pos: ex.vec(50, 50),
209+
width: 64,
210+
height: 64,
211+
scale: ex.vec(2, 2),
212+
color: ex.Color.Gray
213+
});
214+
game.add(screenBox);
215+
console.log('width', screenBox.width);
216+
console.log('height', screenBox.height);
217+
207218
var svgExternal = new ex.ImageSource('../images/arrows.svg');
208219
var svg = (tags: TemplateStringsArray) => tags[0];
209220

src/engine/ScreenElement.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class ScreenElement extends Actor {
3131
this.pointer.useGraphicsBounds = true;
3232
this.pointer.useColliderShape = false;
3333
if (!config?.collider && config?.width > 0 && config?.height > 0) {
34-
this.collider.useBoxCollider(this.width, this.height, this.anchor);
34+
this.collider.useBoxCollider(config.width, config.height, this.anchor);
3535
}
3636
}
3737

0 commit comments

Comments
 (0)