• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

excaliburjs / Excalibur / 14804036802

02 May 2025 09:58PM UTC coverage: 5.927% (-83.4%) from 89.28%
14804036802

Pull #3404

github

web-flow
Merge 5c103d7f8 into 0f2ccaeb2
Pull Request #3404: feat: added Graph module to Math

234 of 8383 branches covered (2.79%)

229 of 246 new or added lines in 1 file covered. (93.09%)

13145 existing lines in 208 files now uncovered.

934 of 15759 relevant lines covered (5.93%)

4.72 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/engine/ScreenElement.ts
1
import { Vector, vec } from './Math/vector';
2
import { Engine } from './Engine';
3
import { Actor, ActorArgs } from './Actor';
4
import { TransformComponent } from './EntityComponentSystem/Components/TransformComponent';
5
import { CollisionType } from './Collision/CollisionType';
6
import { CoordPlane } from './Math/coord-plane';
7

8
/**
9
 * Type guard to detect a screen element
10
 */
11
export function isScreenElement(actor: Actor) {
UNCOV
12
  return actor instanceof ScreenElement;
×
13
}
14

15
/**
16
 * Helper {@apilink Actor} primitive for drawing UI's, optimized for UI drawing. Does
17
 * not participate in collisions. Drawn on top of all other actors.
18
 */
19
export class ScreenElement extends Actor {
20
  protected _engine: Engine;
21

22
  constructor();
23
  constructor(config?: ActorArgs);
24

25
  constructor(config?: ActorArgs) {
UNCOV
26
    super({ ...config });
×
UNCOV
27
    this.get(TransformComponent).coordPlane = CoordPlane.Screen;
×
UNCOV
28
    this.anchor = config?.anchor ?? vec(0, 0);
×
UNCOV
29
    this.body.collisionType = config?.collisionType ?? CollisionType.PreventCollision;
×
UNCOV
30
    this.pointer.useGraphicsBounds = true;
×
UNCOV
31
    this.pointer.useColliderShape = false;
×
UNCOV
32
    if (!config?.collider && config?.width > 0 && config?.height > 0) {
×
UNCOV
33
      this.collider.useBoxCollider(this.width, this.height, this.anchor);
×
34
    }
35
  }
36

37
  public _initialize(engine: Engine) {
UNCOV
38
    this._engine = engine;
×
UNCOV
39
    super._initialize(engine);
×
40
  }
41

42
  public contains(x: number, y: number, useWorld: boolean = true) {
×
UNCOV
43
    if (useWorld) {
×
UNCOV
44
      return super.contains(x, y);
×
45
    }
46

UNCOV
47
    const coords = this._engine.worldToScreenCoordinates(new Vector(x, y));
×
UNCOV
48
    return super.contains(coords.x, coords.y);
×
49
  }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc