Hi,
I have run into an issue where pixels appear to be distorted / get slightly shifted when interacting with other game objects. Here is an example of what’s happening:
Immediately when the game begins we can see that the red health bar above the player square (a sprite) is slightly distorted. The health bar is composed of two Rectangle
game objects - the red health meter and a black stroke for an outline. Right when the game starts, the health bar is distorted.
The translucent black square with white outline is an Inventory window. This is just a Container
with a Rectangle
background which has the translucent black background and white stroke outline.
As shown in the example, when you click and drag the Inventory window, the health bars of both Player and Skeleton distort.
When we kill the skeleton and open up it’s corpse Inventory window we can see that there is a Bandaids (sprite) item and then further clicking/dragging the Inventory windows and Bandaids item you can see that the game objects slightly shift. In addition, the Bandaids sprite appears to “compress” as we see the word, “bandaids” get distorted. Again, this is just a sprite, not a Text object. It’s also not just dragging objects. When we hide/show an Inventory window, the shift/distortion still happens.
We can also see the bottom Hot Bar slightly shift (white outline). Basically, all of my game objects shift in some way.
I think I’ve narrowed it down to an issue with the game config, specifically, roundPixels
and pixelArt
both being set to true. If either one is set to true, the problem is still there, however, if I set both to false
, then the problem does not appear. Of course, if both properties are set to false
then I lose the crisp look of the strokes and sprites (in this case the text).
Has anyone encountered this problem? I’m guessing this is normal behavior, but why would this be happening and how might I be able to prevent it while still enabling pixelArt
/ roundPixels
? My Sprite
squares are whole pixels (except the text I guess?) and it’s happening to the Rectangle
game objects as well. Not sure if it matters, but I use whole integers everywhere. It’s possible I’ve missed some number that needs to be Math.floor
’ed, but I’m not even sure if that’s something affecting my problem.
Any help is much appreciated, thanks!