Issue #506 wontfix

Constructors accepting all possible types

created an issue

I think it would be nice if constructors could accept all types which can be converted to something which the constructor can use. Here's a list of things that constructors could but don't yet accept:

  • Image - FileData
  • SpriteBatch - Filename, File, ImageData, FileData
  • ParticleSystem - Filename, File, ImageData, FileData
  • Source - FileData
  • SoundData - FileData

Edit: I've thought of one reason why this might not be so good for ParticleSystems, and theoretically SpriteBatches too. ParticleSystems could be created quite often, and I assume using an already created Image is much faster and uses less memory than constructing it with a filename/File/ImageData/FileData and having to create a new image every time. SpriteBatches would also have the same problem, but I imagine they'd generally be created much less frequently.

Comments (5)

  1. Bart van Strien

    Hmm, barely any of these make sense, and are incredibly non-obvious, FileData is Data like any other, if a Source was to take FileData, it would be decoded sound, for instance.

  2. hahawoo reporter

    The purpose is for this situation: "I want to make an X from a Y." If this is possible, I think it should be doable.

    Also, I feel that things are currently inconsistent in this regard.

    • If I want to create an ImageData from a filename, I can.
    • If I want to create a ParticleSystem from a filename, I can't, I need to make an Image which I don't need from the filename first.
    • If I want to create an ImageFont from a FileData, I can, but if I want to create a Source from a FileData, I can't.

    If constructors could accept all possible types, it would prevent lovers from needing to create objects that they don't want in order to create an object of a certain type, and also reduce the wondering of whether X can be created from Y, because if it's plausible it should probably be possible.

    I'm a bit confused about Data sorry. Say I wanted to download and play a sound, I think this should be possible:

    downloaded_sound = http.request(url)
    filedata = love.filesystem.newFileData(downloaded_sound, '', 'file')
    source =
  3. Log in to comment