I have a dream that TiledBackground doesn't exist and instead 'Tiled' is a property that you can set on Sprite objects
That would be amazing, would solve so many headaches in my project,
1. I have many cases where I need to write basically the exact same code twice, once for sprites, once for tiledbackgrounds, simply because those objects cant be put in the same family together. And if you want to go one further and have a Family be applicable to Tiled Backgrounds and Sprites, you need to create and code the same family twice. For example some families in my project: PhysicsSprite, PhysicsTile, StructureSprite, StructureTile, ZoneSprite ZoneTile, things like that.
2. shader vtex coordinates work completely different for tiled and sprites, how come?
3. animated tiled objects would be awesome
So anyone know what's up? Is there some incompatibility in design or code that i'm not aware of?
The problem is canvas2D. Apparently, even the tiled aspect of TB's was hackish to get working in canvas2D. It's all perfectly doable in WebGL, just no one has done quite that.
Actually both canvas2d and webgl have their quirks.
With canvas2d the tiledbg is a rectangle with an image pattern fill. Sprites are drawn with the drawimage function, which doesn't have repeat, and is faster than a pattern fill. But yeah, a repeat property could be used to easily switch between the two rendering methods.
With webgl the tiledbaground image needs to be power of two to be able to repeat. The runtime does the resizing for you when the object type is first created, and this may also be why things are different with effects. Other than the size issue, the difference between sprite and tiledbackground is mainly just a webgl texture setting as I recall. Webgl2 allows for non-power of two texture repeating but it's a long way off. Another possibility would be to write a shader to do the repeating but this wouldn't be as fast.
Develop games in your browser. Powerful, performant & highly capable.
There are a couple of issues that prevent us easily putting a "tiled" property on Sprite:
I think the easiest solution is a way to add animations to Tiled Background with some provision for spritesheeting, but this is complicated and doesn't even solve all the problems!
revert to bounding-box in tiled mode
I think it's unusual for someone to want a tiled sprite without using bounding box collision mask, so if the 'tiled' option didn't affect collision masks at all, I think people would still manually set them to be bounding box.
If the 'tiled' option is clearly described as something that -only- affects rendering, then I think that confusing trap can be avoided, or at least it's no more confusing than how people could already accidentally have a collision mask that doesn't match their sprite image.
but either way.. i understand now that this is a big technical problem as well, so that seems fair enough that tiled sprites aren't a thing
thanks for the responses C-7 R0J0hound Ashley