Anti-Alias and WebGL support looks strange

Hello,

I created a new sprite node and changed the node rotation from 0 to 30 (does not matter which number).
I attached a sprite frame to the relevant section in the cc.Sprite component.

And now I noticed that when I am rotating an object it gets a very bad Anti Aliasing.

So I dig in to find out why and I cannot find any solution in the forum.
I tried to add the following code to the node script:

onLoad () {
    cc.view.enableAntiAlias(true);
    // And i tired this too:
    cc.view.enableAntiAlias(false);
}

So I made another research and I find out that there could be a solution to set texture filter like this:

    onLoad () {
        this.sprite = this.node.getComponent(cc.Sprite);
        cc.view.enableAntiAlias(true);
        // Tried also:
        cc.view.enableAntiAlias(false);

        if (!this.sprite) {
            return;
        }

        const texture = this.sprite.spriteFrame.getTexture();
        texture.setFilters(cc.Texture2D.Filter.LINEAR, cc.Texture2D.Filter.LINEAR);
        this.sprite.spriteFrame = new cc.SpriteFrame(texture);
    }

And still did not work at all!

So I tried to figure out why it is happening here and in some old thread I noticed that I need to make sure that I am running on WebGL mode. The debugger shows me that web gl is set to 0 and it should be set to 2. How can I enable WebGL mode / canvas?

So somewhere in the documentations, the docs stated that cocos creator v2 and above are always support WebGL so why can I see that the WebGL mode (on the attached image above) is 0 and not 2?

When I am running the following command it shows that renderMode is 0:

cc.game.config

Please help me to fix this…

Hello

WebGL is the only mode supported by latest versions of Coco. The debugger information is just wrong.

To enable anti alisasing, I use this command, in a js file outside of my game logic :

cc.macro.ENABLE_WEBGL_ANTIALIAS=true;

This should do the trick.

If not, I sometimes enable the “premultiply alpha” option in the sprite settings.

CaptureCocosProperty

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.