【发布时间】:2022-07-04 15:50:45
【问题描述】:
我创建了 3 个画布纹理:
this.textures1 = this.textures.createCanvas('canvastextures1', 450, 170)
this.textures2 = this.textures.createCanvas('canvastextures2', 410, 180)
this.textures3 = this.textures.createCanvas('canvastextures3', 400, 210)
this.land1 = this.textures.get(MAPOPTIONS.BASE1_NAME).getSourceImage()
this.land2 = this.textures.get(MAPOPTIONS.BASE2_NAME).getSourceImage()
this.land3 = this.textures.get(MAPOPTIONS.BASE3_NAME).getSourceImage()
this.textures1.draw(0, 0, this.land1)
this.textures2.draw(0, 0, this.land2)
this.textures3.draw(0, 0, this.land3)
this.textures1.context.globalCompositeOperation = 'destination-out'
this.textures2.context.globalCompositeOperation = 'destination-out'
this.textures3.context.globalCompositeOperation = 'destination-out'
然后我通过Phaser.Physics.Arcade.Sprite 类将 3 个画布纹理添加到 3 个 Sprite 对象,并为它们启用 Physic。最后,我将它们按Phaser.GameObjects.Group分组
当对象与组重叠时,我在 groupSprite 中调用overlap(groupSprite, object) 函数到ERASE 画布纹理(子弹与土地并创建一个洞)。
this.activeTextures = this.textures.get('canvastextures3')
this.activeTextures.context.beginPath()
this.activeTextures.context.arc(Math.floor(overlap2.x), Math.floor(overlap2.y), 50, 0, Math.PI * 2)
this.activeTextures.context.fill()
this.activeTextures.update()
问题是 Sprite 对象不跟随画布纹理更新。有没有人有任何想法?谢谢。
【问题讨论】:
标签: typescript sprite updates phaser-framework