phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.1k stars 7.09k forks source link

SpriteBatch problems #2245

Closed Darky-Lucera closed 8 years ago

Darky-Lucera commented 8 years ago

Hi!

I observed some problems using spriteBatch (using CANVAS on Phaser 2.4.4)

1- Sometimes the texture coordinates are not well calculated when using atlases for sprites/images. The spriteBatch draws a bigger texture area (sometimes). It seems to me that it draws until the next power of two to the right and to bottom.

Example: if you have a texture atlas of 100x40 it seems to draw 128x64.

2- Sometimes the image position is not well calculated when using atlases for sprites/images with animations.

I have a head making nod that works perfectly when its alone but it jumps a bit when in a spriteBatch. It has anchor (0.5, 1) and a yoyo animation that rotates it.

3- The textures with negative scale are not well drawn.

I can fix that changing a line of code in the function: PIXI.SpriteBatch.prototype._renderCanvas

This line: if (child.rotation % (Math.PI * 2) === 0) For this one: if (child.rotation % (Math.PI * 2) === 0 && child.scale.x >= 0 && child.scale.y >= 0)

But the image with negative scale is not well positioned and is a bit blurred (all it's ok when alone).

Thanks

Darky-Lucera commented 8 years ago

Another one:

4- Seems that the hitAreas of the images/sprites in the spriteBatch do not work properly. It seems that are scaled and in a first plane disallowing buttons that were in front.

These same hitAreas worked well out of the spriteBatch.

photonstorm commented 8 years ago

Closing due to several months of inactivity. A stand-alone running code example is needed to investigate this further.