-
Hi, Been experimenting with excalibur, and part of my game includes firing solid beams, which I'm doing as a More specifically. I'm recalculating the beam in This simplified codepen -> https://codepen.io/davobutt/pen/VwqdBJy A line drawn on a plain Any help would be gratefully received. Also happy to hear I'm doing this in completely the wrong way! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
@davobutt Great question! I think you found a bug with Lines! After digging into this, there is a zero dimension bound when creating horizontal lines (if the line is slightly askew the bound is non zero). In the case of I've created an issue and should be able to work this soon! To workaround this you can manually set a height on the line class Beam extends ex.Actor {
public length;
constructor(options, length) {
super(options);
this.graphics.anchor = ex.Vector.Zero;
this.length = length;
const longLine = new ex.Line({
start: ex.vec(0, 0),
end: ex.vec(this.length, 0),
thickness: 26,
color: ex.Color.White
});
longLine.height = 26; // workaround bug
//console.log(longLine.width, longLine.height);
//console.log(this.graphics.localBounds);
this.graphics.use(longLine);
}
Hope this helps! |
Beta Was this translation helpful? Give feedback.
-
This seems to be hiding another potential bug or maybe its a feature? The culprit seems to be here: As I said, I'm not really sure if this classifies as a bug or not, but it would theoretically be possible to add graphics to an actor that are completely offscreen (not only partially like the line in this example where the offscreen check failed due to the 0 height) and those would then be proccessed and tried to be drawn (offscreen) by the GraphicsSystem since the Actor itself is on the screen. Side note: my first instinct to workaround the long Beam not beeing drawn, before diving into the implementation details was to override isOffScreen() in the Beam class, but that method isn't really called anywhere but during testing. |
Beta Was this translation helpful? Give feedback.
@davobutt Great question! I think you found a bug with Lines!
After digging into this, there is a zero dimension bound when creating horizontal lines (if the line is slightly askew the bound is non zero). In the case of
longBeam
it's bound is 1001x0. That zero height is playing havoc with the offscreen culling routine and causing it to think it's offscreen when it really isn't.I've created an issue and should be able to work this soon!
To workaround this you can manually set a height on the line
longLine.height = 26
or make the line slightly askew: