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.23k stars 7.1k forks source link

Phaser3.61-beta.3 + Fri13Patch dynamicTexture bug #6654

Closed michalfialadev closed 1 year ago

michalfialadev commented 1 year ago

Version

Description

I have an existing game that runs fine on Phaser3.60-b19, Phaser3.60, Phaser3.61-beta.1, Phaser3.61-beta.3, but images using dynamicTexture source fail to show up on Phaser3.61-beta.3 with Fri13 hotfix applied.

Fri13 hotfix on github: https://github.com/photonstorm/phaser/compare/v3.61.0-beta.3...master

Fri13 hotfix in VSCode: image

Game running on beta3: image

Game running on beta3 with Fri13 hotfix applied: image

Code used to create DT and then copy texture pixels and frames from existing Texture to said DynamicTexture (this should not be an issue pre-fri13-update, but im pasting it anyway, in case youd like to create your own mini repro to test a specific case):

public Build(): void
{
    const bg0Texture: Phaser.Textures.Texture = this.scene.textures.get(LoaderFileKeys.cardsDeck + 0);
    if (bg0Texture.key != "__MISSING") {
        const size: any = bg0Texture.customData["size"];
        this.cardsDeckTexture = this.scene.textures.addDynamicTexture(LoaderFileKeys.cardsDeck, size.w, size.h);
    }

    const curCardsDeckIndex: number = OptionsDataManager.GetItemDataByItemId(OptionsItemKeys.cardDeck).value as number;
    this.SetCardsDeckIndex(curCardsDeckIndex);
}

private SetCardsDeckIndex(cardsDeckIndex: number): void
{
    const sourceTextureKey: string = LoaderFileKeys.cardsDeck + cardsDeckIndex;
    const cardsDeckFrames: Record<string, Phaser.Textures.Frame> = this.scene.textures.get(LoaderFileKeys.cardsDeck+cardsDeckIndex).frames as Record<string, Phaser.Textures.Frame>;
    for (var frameKey in cardsDeckFrames) {
        const frame: Phaser.Textures.Frame = cardsDeckFrames[frameKey];
        const pivotX: number = frame.customPivot ? frame.pivotX : frame.centerX;
        const pivotY: number = frame.customPivot ? frame.pivotY : frame.centerY;
        this.cardsDeckTexture.stamp(sourceTextureKey, frameKey, frame.cutX + pivotX, frame.cutY + pivotY);
        this.cardsDeckTexture.add(frameKey, frame.sourceIndex, frame.cutX, frame.cutY, frame.width, frame.height);
    }
}

Adding image from the newly created filled in dynamic texture to scene does not show up at all (no errors, but the DT seems to be empty or similar?).

Changing pipeline mobile/multi does not change anything.

Additional Information

Any other way i can help?

photonstorm commented 1 year ago

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.