Jump to content

Nearest Neighbor


Recommended Posts

I may have missed this somewhere else, but was unable to find it. Sorry if that is the case.


I would like to be able to scale sprites with nearest neighbor filtering so they do not become blurry. I have modified phaser.js to do this myself since the beginning, but with the frequent updates, I wanted to see if there was a way already built in.



Link to comment
Share on other sites

With canvas it's an "all on" or "all off" situation, you can't scale just some sprites with NN filtering and not others.


If you wish to turn it on then just set the antiAlias parameter to "true" when you create your game instance (it's the very last parameter given to Phaser.Game).


If you wish to enable it after the game has started for some reason then do:

Phaser.Canvas.setSmoothingEnabled(game.context, false)

Note: This doesn't work in WebGL! Canvas only. Also doesn't work correctly in all mobile browsers (but then what does?)

Link to comment
Share on other sites

P.S. Native english speakers, is it correct in previous sentence to say 'searched', or 'searched for' is better?


You generally use "searched for" when you are referring to what you are searching for. As in "you have searched for this topic."


You would use "searched" by itself if you are referencing where the searching is happening. As in "you have searched the forum."

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...