Why is TiledBackground seperate from Sprite object type?

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • 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.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • There are a couple of issues that prevent us easily putting a "tiled" property on Sprite:

    • the collision masks work differently: you can put a custom collision mask on each frame of a Sprite, but not on a tiled background, because we don't support tiling collision masks. If you could tile a Sprite, either we would have to do a lot of work to implement tiling of collision masks (which could present some very difficult implementation problems), or collisions just suddenly revert to bounding-box in tiled mode, which is the kind of confusing trap that people get upset about ("why did my collisions suddenly stop working?!").
    • the rendering works differently: each Tiled Background object uses a repeating texture, which is different to a non-tiling texture in OpenGL. Also due to the way OpenGL works it's most convenient to exclude these images from spritesheeting, so each tiled texture is always its own texture with no padding or other content (which makes the texture repeat modes easy to use). If Sprite has an option to enable this, it becomes quite complicated. If you can change it per instance or at runtime, you must duplicate the entire set of images (doubling the memory usage) to allow for the tiled mode. Only allowing it to be a global option for each type of sprite is easier, but even this is not so straightforward: if you have 500 animation frames, due to the fact they are not spritesheeted, this turns in to 500 separate images after export, and having too many images has been the source of problems before.

    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

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)