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

Changes to FlxStrip break FlxTiledSprite #2694

Closed
EliteMasterEric opened this issue Dec 9, 2022 · 3 comments · Fixed by #2696
Closed

Changes to FlxStrip break FlxTiledSprite #2694

EliteMasterEric opened this issue Dec 9, 2022 · 3 comments · Fixed by #2696

Comments

@EliteMasterEric
Copy link
Contributor

With the addition of changes made by @UncertainProd in #2671, FlxTiledSprite no longer renders properly. The tiled sprite is now stretched out instead of repeated over the sprite's width.

I considered posting this issue to flixel-addons, but no changes were made to FlxTiledSprite; rather, the code change to FlxStrip has caused an issue which potentially affects anything using FlxStrip.


  • Haxe version: 4.2.5
  • Flixel version: git commit e1fbdc4
  • OpenFL version: 9.2.0
  • Lime version: 8.0.0
  • Affected targets: Windows and Linux native were both tested

Code snippet reproducing the issue:

https://github.com/MasterEric/FlxTiledSprite-TestBench


Observed behavior:

incorrect

Expected behavior:

correct

@Geokureli
Copy link
Member

Gonna do some testing, soon, but ill likely revert the breaking PR around monday. Sorry about this

@UncertainProd
Copy link
Contributor

I think this is due to the fact that beginShaderFill doesn't have an option to repeat the texture that its filling with, like how beginBitmapFill does. I guess we can add an if check before choosing whether to use beginShaderFill or beginBitmapFill.
I think adding a boolean field called repeat to FlxDrawTrianglesItem and then doing something like this can work:

if (!repeat && shader != null)
	camera.canvas.graphics.beginShaderFill(shader);
else
	camera.canvas.graphics.beginBitmapFill(graphics.bitmap, null, repeat, (camera.antialiasing || antialiasing));

It only has the downside that only one of FlxStrip.repeat and FlxStrip.shader can work at a time (aka setting FlxStrip.repeat to true will also make it so shaders have no effect on the sprite).

What do you guys think?

@EliteMasterEric
Copy link
Contributor Author

I think this is due to the fact that beginShaderFill doesn't have an option to repeat the texture that its filling with, like how beginBitmapFill does. I guess we can add an if check before choosing whether to use beginShaderFill or beginBitmapFill.
I think adding a boolean field called repeat to FlxDrawTrianglesItem and then doing something like this can work:

if (!repeat && shader != null)
	camera.canvas.graphics.beginShaderFill(shader);
else
	camera.canvas.graphics.beginBitmapFill(graphics.bitmap, null, repeat, (camera.antialiasing || antialiasing));

It only has the downside that only one of FlxStrip.repeat and FlxStrip.shader can work at a time (aka setting FlxStrip.repeat to true will also make it so shaders have no effect on the sprite).

What do you guys think?

This would work for fixing the issue but obviously make for inconsistent behavior.

Make sure the change is well-documented, and ideally look into potentially modifying beginShaderFill thus making it more versatile

UncertainProd added a commit to UncertainProd/flixel that referenced this issue Dec 10, 2022
…eFlixel#2694

- The repeat field in FlxDrawTrianglesItem will specify if the bitmap
will be repeated (or tiled) during rendering.
- As of this commit, FlxDrawTrianglesItem will use bitmapFill instead of
shaderFill if repeat is set to true. This should potentially fix issues
like HaxeFlixel#2694 where drawing tiled sprites would not work when drawing with
shaderFill
- This would also disallow shaders for any FlxDrawTrianglesItem
instance with repeat set to true.
UncertainProd added a commit to UncertainProd/flixel that referenced this issue Dec 12, 2022
Geokureli added a commit that referenced this issue Jan 3, 2023
* Fixes to FlxStrip rendering (fixes #2694)

* Removed an extra whitespace

* Cleanup after merge

* convert tabs to spaces, indent nested #ifs

Co-authored-by: George FunBook <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants