Phaser 3 BitmapText Tint 突然不工作

Phaser 3 BitmapText Tint suddenly not working

我的代码前一分钟工作正常,下一分钟就不行了。

问题与 BitmapText 色调有关。

我正在使用 Phaser 3.54.0 的 CDN。

显示色调有什么原因吗?我没有接触与 BitmapText 变量相关的代码。

这是代码...


export default class CardBase extends Phaser.GameObjects.Container {
    constructor(data) {
        let { scene, x, y, name, card, image, depth, black, green, purple, red, yellow, products, counter } = data
        let spriteCard = new Phaser.GameObjects.Sprite(scene, 0, 0, card)
        let spriteImage = new Phaser.GameObjects.Sprite(scene, 0, 20, image)
        let textBlack = new Phaser.GameObjects.BitmapText(scene, 80, -120, 'pressstart', black, 20)
        let textGreen = new Phaser.GameObjects.BitmapText(scene, 60, -50, 'pressstart', green, 20)
        let textPurple = new Phaser.GameObjects.BitmapText(scene, 60, 0, 'pressstart', purple, 20)
        let textRed = new Phaser.GameObjects.BitmapText(scene, 60, 50, 'pressstart', red, 20)
        let textYellow = new Phaser.GameObjects.BitmapText(scene, 60, 120, 'pressstart', yellow, 20)
        let textProducts = new Phaser.GameObjects.BitmapText(scene, 60, -120, 'pressstart', products, 24)
        let textCounter = new Phaser.GameObjects.BitmapText(scene, 0, -120, 'pressstart', counter, 36)
        textBlack.tint = 0
        textGreen.tint = 0
        textPurple.tint = 0
        textRed.tint = 0
        textYellow.tint = 0
        textProducts.tint = 0
        textCounter.tint = 0
        let textName = new Phaser.GameObjects.BitmapText(scene, 0, 0, 'pressstart', name, 16, Phaser.GameObjects.BitmapText.ALIGN_CENTER)
        super(scene, x, y, [spriteCard, spriteImage, textName, textBlack, textGreen, textPurple, textRed, textYellow, textProducts, textCounter])
        this.spriteCard = spriteCard
        this.spriteImage = spriteImage
        this.textName = textName
        this.cardname = name
        this.depth = depth
        this.scene = scene
        this.textBlack = textBlack
        this.textGreen = textGreen
        this.textPurple = textPurple
        this.textRed = textRed
        this.textYellow = textYellow
        this.textProducts = textProducts
        this.textCounter = textCounter
        this.black = black
        this.green = green
        this.purple = purple
        this.red = red
        this.yellow = yellow
        this.products = products
        this.counter = counter
        this.scene.add.existing(this)
    }

    set black(newBlack) {
        this._black = newBlack
        this.textBlack.text = this._black
    }
    
    get black() {
        return this._black
    }
}

我怀疑(我可能是错的)我的问题与我的浏览器有关。我有更新到期 Chrome。事实证明 Phaser.AUTO 默认为 Canvas 而不是 WebGL。似乎 WebGL 不知何故不可用。

由于 BitmapText Tint 仅适用于 WebGL,因此当 WebGL 不可用时它会受到影响。没用。

我重新启动电脑后 Chrome 上的更新生效,一切恢复正常,Tint 再次工作。