You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If non-integer values are passed to the Phaser.Game constructor, then precision errors can lead to TileSprite not rendering correctly.
I am drawing TileSprite images (256 x 64 and 256 x 32) and they are rendering incorrectly. I am only tiling horizontally.
The 256 x 64 image is rendering as if I had set sprite.tilePosition.y = 1, although tilePosition.y is actually 0. The 256 x 32 image is rendering as if I had set sprite.tilePosition.y = -1, although tilePosition.y is actually 0.
The console reports Phaser v2.4.4 and Pixi v2.2.9. The bug seems to affect both CANVAS and WEBGL rendering. I have seen the bug on both Firefox and Chrome.
After quite a bit of debugging I found that the bug is caused by non-integer values passed to width and height of the Phaser.Game constructor. Below is sample code that replicates the issue.
<html>
<head>
<script type="text/javascript" charset="utf-8" src="lib/phaser.min.js"></script>
<script>
var x;
var game = new Phaser.Game(1036.8, 613.8000000000001, Phaser.CANVAS, 'test_div');
var testState = {
preload: function() {
this.game.load.image('floor', 'asset/app1/seafloor_256x64.png');
},
create: function() {
this.floor = this.game.add.tileSprite(0, this.game.world.height - 100, this.game.camera.width, 64, 'floor');
this.floor.anchor.set(0.0, 1.0);
x = this.floor;
}
}
game.state.add('test', testState);
game.state.start('test');
</script>
</head>
<body>
<div id='test_div'></div>
</body>
</html>
I do not know the best way to address this bug. For now, I ensure the game sizes are integers.
(For anyone wondering, the strange game sizes came from code that automatically adapts to different mobile platforms.)
The text was updated successfully, but these errors were encountered:
…ssed through Math.floor first. This ensures you can never create a game width non-integer dimensions, which has all kinds of implications - from browser performance to breaking things like TileSprite rendering (#2262)
What you're seeing is a result of canvas pixel rounding. However I believe the fix is easy, because a Game should never have non-integer dimensions. So this is now enforced in the Game constructor, which should prevent the problem from arising (it's still possible to call Game.resize and mess things up, but if you've gone that far on your head be-it I think)
If non-integer values are passed to the Phaser.Game constructor, then precision errors can lead to TileSprite not rendering correctly.
I am drawing TileSprite images (256 x 64 and 256 x 32) and they are rendering incorrectly. I am only tiling horizontally.
The 256 x 64 image is rendering as if I had set sprite.tilePosition.y = 1, although tilePosition.y is actually 0. The 256 x 32 image is rendering as if I had set sprite.tilePosition.y = -1, although tilePosition.y is actually 0.
The console reports Phaser v2.4.4 and Pixi v2.2.9. The bug seems to affect both CANVAS and WEBGL rendering. I have seen the bug on both Firefox and Chrome.
After quite a bit of debugging I found that the bug is caused by non-integer values passed to width and height of the Phaser.Game constructor. Below is sample code that replicates the issue.
I do not know the best way to address this bug. For now, I ensure the game sizes are integers.
(For anyone wondering, the strange game sizes came from code that automatically adapts to different mobile platforms.)
The text was updated successfully, but these errors were encountered: