Make it possible to reference single tiles in a tilesource by number id (DEF-3213)

As always, just yell at me if I’m missing something, and this is handled in some way unknown to me.

It seems like you can only set tilesource tiles on a sprite by creating single frame animations, and sending the play_animation message to the sprite.

The fact that the sprite only sees animations, as opposed to frames is fine (and even elegant), but the fact that you can seemingly only change a sprite by referencing a hand created, design time, animation is a pain. There should be an option to do it the same way its handled on tilemaps, by number id. Im not sure how exactly that would be implemented (perhaps simply by having default, single frame animations for each tile always available, or created when needed), but at the end of the day I should be able to do something similar to this:

msg.post(sprite_url, "play_animation", {nr_id = 345})

without having to first create an animation named 345 (and one for the 344 preceding it).

It isnt hard to see why this is almost required when working with very large sprite sheets, in a procedural/programmatic way. Not all game design concepts are strictly design time concepts.

edit is there a way to procedurally add animations? That would at least handle most of the tedium (though I still think some kind of no-nonsense frame reference by number would be best)

2 Likes

You don’t have to create an animation to change the current image of a sprite. The play_animation message also accepts the name of a single image within the atlas.

Oh, now I see that you mention tilesource and not atlas… Yeah, that’s currently not possible as far as I know.

Capture

This is what I get to do 32 times, and it could be much worse. It effectively makes one want to flat out avoid some things. (imagine it were a 20x20 grid of 400 tiles… yes its possible but who wants to tediously do this)

As I mentioned in chat, I think that when trying to generalize the engines components, procedural generation and non design time concepts should be taken into consideration.

Anyways, thanks for taking a look

But this assumes that you’re using tilesources instead of atlases for your sprites. I generally prefer to stick my images into an atlas instead of a tilesource for sprite graphics. Now, I understand that sometimes you prefer to have the graphics in a tilesource, especially if it’s shared between tilemaps and sprites. Is that your usecase?

Oh, and this could be generated by a Python script as well. All files are simple text files so they’re easy to modify by other tools.

My use case requires me to do this, but I believe its besides the point. An atlas would just shift the tedium over to creating 400 individual images (which doesnt even make sense when working with such highly symmetrical assets), naming them all appropriately, and going from there. In fact, it may be more tedious (correct me if im wrong, i dont have any experience with the atlases.)

Im of the firm opinion that anything in the engine should be easily manipulated programatically, and that the defold interface should only be a convenience. It shouldnt take center stage to the point of forcing one to build games around the interface, at least not for such trivial things (obviously the engine itself 2d focused for instance, and i shouldn’t be designing an FPS in it). Otherwise you run into exactly these kinds of issues (and eventually it turns into unity syndrome)

Yes it could be generated using a python script. But it could also all just be done in an assembly language. The point of an engine is to avoid stuff like that.

I really dont think this is unreasonable lol (though it may not be feasible)

edit: I should at the very least be able to create animations in script. This isnt a drag and drop engine.

My point was that there’s a workaround. Not that we shouldn’t solve the original issue, which is to use an individual image of a tilesource as the source for a sprite. I agree that this should be possible.

Ah my bad. I genuinely thought you were waving it off as something that can just be handled by a workaround, and is therefore not worth worrying about.

edit: and jesus, how do I quote. Im hitting reply but it doesnt seem to be the same thing.

Ah there we go :stuck_out_tongue:

There is also a python module that simplifies editing/creating Defold files DefTree: A python module for editing Defold files

3 Likes

Created a ticket: DEF-3213

1 Like

With symmetrical assets this is way easier. Use ImageMagick or some other tool to cut up and name the images, then drop in atlas and you are good to go.

1 Like

Hi! I would also appreciate this. I am currently dealing with 240 tiles and would love away to set a sprite straight from the tilesource. But, i will look into the text file and see what I can do.

1 Like