Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[3.50] RenderTexture - erase doesn't work correctly with Canvas renderer #5422

Closed
vforsh opened this issue Dec 2, 2020 · 2 comments
Closed

Comments

@vforsh
Copy link
Contributor

vforsh commented Dec 2, 2020

Version

3.50 - latest from the repo

Description

This issue occurs only with Canvas renderer. When I erase with the texture key (e.g. renderTexture.erase("texture")) it draws the texture instead of erasing.
2020-12-02_17-03-02

Example Test Code

Live example - https://robowhale.com/html5/phaser-issues/render-texture-erase/?forceCanvas=1
Source code - https://robowhale.com/html5/phaser-issues/render-texture-erase/js/index.js

preload() {
		this.load.image('bg', 'assets/graphics/bg.png')
		this.load.image('red_rect', 'assets/graphics/red_rect.png')
	}
	
	create() {
		this.addImage()
		this.addRenderTexture()
	}
	
	private addImage() {
		this.addLabel("Original Image", 250, 40)
		this.image = this.add.image(250, 320, "bg")
	}
	
	private addRenderTexture() {
		this.addLabel("Render Texture", 750, 40)
		
		this.renderTexture = this.add.renderTexture(750, 320, this.image.width, this.image.height)
		this.renderTexture.drawFrame("bg")
		this.renderTexture.setOrigin(0.5)
		
		let position = this.image.getTopLeft()
		let rect = this.add.image(position.x, position.y, "red_rect")
		rect.setOrigin(0)
		
		this.renderTexture.erase("red_rect", 0, 0)
	}

Additional Information

The issue occurs only with canvas renderer, WebGL is fine - https://robowhale.com/html5/phaser-issues/render-texture-erase/?forceCanvas=0

Probably related to #5412

@photonstorm
Copy link
Collaborator

Just tested this example against the master branch in Canvas mode and it's erasing properly now:

http://labs.phaser.io/view.html?src=src%5Cgame%20objects%5Crender%20texture%5Cerase%20part%20of%20render%20texture%20canvas.js&v=dev

Please check for yourself, however.

@vforsh
Copy link
Contributor Author

vforsh commented Dec 3, 2020

In this example, you erase with the existing game object and it works fine, yes

But if you will erase using the texture key it will draw it instead of erasing
2020-12-03_18-36-23

Try use (lines 42 and 49)
rt.erase("brush", pointer.x - 16, pointer.y - 16);
instead of
rt.erase(brush, pointer.x - 16, pointer.y - 16);

And you will see the issue

photonstorm added a commit that referenced this issue Dec 3, 2020
… and a texture frame, only with Game Objects. It now works with both. Fix #5422
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants