Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Frame doesn't change with tint on - in canvas mode only #2453

Closed
spayton opened this issue Apr 26, 2016 · 3 comments
Closed

Frame doesn't change with tint on - in canvas mode only #2453

spayton opened this issue Apr 26, 2016 · 3 comments

Comments

@spayton
Copy link
Contributor

spayton commented Apr 26, 2016

This Issue is about

  • A bug in the API

When in canvas mode, with a sprites tint set to something other than 0xFFFFFF, if the frame is changed the sprite display doesn't update, it does remember the required fram but won't display it until the tint is removed by setting to 0xFFFFFF.

This is demonstrated in this Phaser sandbox example here. Two game instances are created, the top one is with the default sandbox canvas mode of AUTO (should be labelled WEBGL unless your browser doesn't support it), the bottom one is fixed to CANVAS (will be labelled CANVAS).

The following keyboard keys are setup:
1 - change to frame 1
2 - change to frame 2
3 - change to frame 3
T - toggle tint

To show the problem, press T, then change the frames with 1,2,3. You'll see that the top mummy changes frame when red, the bottom mummy doesn't. Hit T again and you'll see the bottom mummy switch to it's correct frame.

I can see why this is happening, the requiresReTint flag appears to be getting cleared in the preUpdate before rendering (note that this doesn't happen if the frame is being changed by the animation manager). I think there's a choice here on how to fix this, a quick fix to address this issue or a more thorough fix to also cache the tinted frame reference to be able to detect exactly when a tinted canvas needs regenerating.

@photonstorm
Copy link
Collaborator

A better question to me is why on earth is preUpdate clearing the flag, and not the tinting process itself. Will have a play with this and see what can be done, thanks for opening the issue.

@spayton
Copy link
Contributor Author

spayton commented May 17, 2016

Yup, that's a better question. It's not clear looking at the commit history what area you were working in that might explain why this was added, so suspecting the fix wouldn't be as trivial as it seemed I left it.

The flag clearing was initialy added here on 8/5/2015: a1102d4

And then beefed up a few days later with a texture check here: 4aa22e2

photonstorm added a commit that referenced this issue May 17, 2016
…a either `Sprite.frame` or `Sprite.frameName` wouldn't re-tint the new frame, and would become stuck on the old frame in Canvas mode (thaks @spayton #2453)
@photonstorm
Copy link
Collaborator

Ok I can't see any reason at all why the tint process shouldn't be responsible for it, so I've made that change and your test case now works (as do the old examples), so I'm happy this is resolved.

Until the reason I added it in the first place comes back to bite my ass :)

chao-xian added a commit to chao-xian/phaser that referenced this issue Jun 2, 2016
* upstream/master: (990 commits)
  Phaser 2.4.8 release.
  Update Documentation in Game.js
  Sprites that had a tint on them, that then had their frame changed via either `Sprite.frame` or `Sprite.frameName` wouldn't re-tint the new frame, and would become stuck on the old frame in Canvas mode (thaks @spayton phaserjs#2453)
  Sounds played using the Audio tag, set to loop, would get caught in an endless pause-play loop cycle (thanks @rroylance phaserjs#2473)
  Position in Body.reset phaserjs#2470
  Sounds played using the Audio tag, that were paused and then resumed again (either directly in code, or via a game pause event) would not resume from the point at which they paused (thanks @rroylance phaserjs#2473)
  If you set Game.renderType to `Phaser.HEADLESS` it will no longer render the output to the canvas. The canvas is still created (although not added to the DOM), as it's required internally, but no rendering now takes place on it (thanks @ForgeableSum phaserjs#2464)
  Arcade Physics Body has a new property `worldBounce`. This controls the elasticity of the Body specifically when colliding with the World bounds. By default this property is `null`, in which case Body.bounce is used instead. Set this property to a Phaser.Point object in order to enable a World bounds specific bounce value (thanks @VitaZheltyakov phaserjs#2465)
  Fixed a bug in Arcade Physics Body.preUpdate which would incorrectly apply the position of an offset Body (one which has had Body.setSize used on it) when combined with a Sprite with a non-zero anchor (thanks @SBCGames phaserjs#2470)
  Arcade Physics has had a new `world` argument added to the following functions: `distanceBetween`, `distanceToXY`, `distanceToPointer`, `angleBetween`, `angleToXY` and `angleToPointer`. The argument (which is false by default), when enabled will calculate the angles or distances based on the Game Objects `world` property, instead of its `x` and `y` properties. This allows it to work for objects that are placed in offset Groups, or are children of other display objects (thanks @Skeptron for the thread phaserjs#2463)
  TS defs fix phaserjs#2475
  Text.setStyle has a new argument `update` which will optionally automatically call `updateText` after setting the new style (thanks @staff0rd  phaserjs#2478)
  fix generateTexture return type
  BitmapData.copy, and by extension any method that uses it, including BitmapData.draw, drawGroup and drawFull, now all support drawing RenderTexture objects. These can either be passed directly, or be the textures of Sprites, such as from a call to generateTexture.
  Docs update.
  Removed, this has gone to its own branch.
  BitmapData.drawGroupProxy is now capable of iterating through Sprites that have children, and also now uses the world positions for drawing instead.
  Swap to use worldScale instead of worldTransform.
  Revert worldScale setter.
  Typo fix.
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants