supertux
supertux copied to clipboard
Linked sprite support, custom `MovingSprite` light sprites
Custom light sprites can now be added to all objects, which inherit MovingSprite. Setting a custom color for the light sprite is also possible, as long as the object is not designed to use foreign color values (for example, from an option).
To add a light sprite with an RGB color of 0.5, 0.2, 0.25, in a .sprite file:
(linked-sprites
(light "path/to/light/sprite" 0.5 0.2 0.25)
)
Keep in mind that specifying color values is optional. The entry can also end after specifying the file.
Additionally:
- Objects which utilize more than 1 sprite are now able to get the files of their additional sprites from the main one's
linked-spriteslist (the same block wherelightsprites can also be added, as shown above). This allows for expanded sprite customization for objects.
To add linked sprites, in a .sprite file:
(linked-sprites
(key "path/to/sprite")
(key2 "another/sprite/file")
)
Linked sprites can be added under sprite actions, too. If a sprite with the same key is found in the general linked sprites block and the action-specific one, the sprite specified by the action will be prioritized, thus overriding the default linked sprite file.
Sprites, which the specific object does not support, will be ignored.
- Sprite actions now support the
flip-offsetproperty, which determines how much the sprite should be vertically offset when flipped vertically.
Do the light sprites work per action or is it one for all?
Do the light sprites work per action or is it one for all?
One for all, currently. I think per-action could be done, though.
One for all, currently. I think per-action could be done, though.
That would be nice to have for sure
One for all, currently. I think per-action could be done, though.
I'm thinking it could be done by having the same block available in action, and if a sprite with the same key as in the global block is available, then prioritize the one of the action.
What was this trying to fix?
What was this trying to fix?
Hardcoded sprites.
@Vankata453 My brain explodes by trying to form this words so I'll do it like this. Can I:
- Make a light
.spritefile with 2+ actions - Link that
.spritefile to the object's .sprite file - Assign individual actions of light sprite to each action of the object .sprite if needed
The way I originally was hoping we could achieve that was through a special tag within an action.
Here is an example Dive Mine.sprite file using the theoretical ([key name]-action "[action name]") tag:
(action
(name "left")
(fps 12.0)
(hitbox 14 19 32 32)
(ticking-glow-action "idle")
(images "left-0.png"
"left-1.png"
"left-2.png"
"left-3.png"
"left-4.png"
"left-5.png"
"left-6.png"
"left-7.png"
"left-8.png"
"left-9.png"
"left-10.png"
"left-11.png"))
(action
(name "right")
(fps 12.0)
(hitbox 14 19 32 32)
(ticking-glow-action "idle")
(mirror-action "left"))
(action
(name "iced-left")
(hitbox 5 8 32 32)
(ticking-glow-action "idle")
(images "left-0.png"))
(action
(name "iced-right")
(hitbox 5 8 32 32)
(ticking-glow-action "idle")
(mirror-action "iced-left"))
(action
(name "ticking-left")
(fps 15.0)
(hitbox 14 19 32 32)
(ticking-glow-action "ticking")
(images "ticking-0.png"
"ticking-1.png"
"ticking-2.png"
"ticking-3.png"
"ticking-4.png"
"ticking-5.png"
"ticking-6.png"
"ticking-7.png"
"ticking-8.png"
"ticking-9.png"))
(action
(name "ticking-right")
(fps 15.0)
(hitbox 14 19 32 32)
(ticking-glow-action "ticking")
(mirror-action "ticking-left"))
(linked-sprites
(ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite")
)
)
The way the tag would work is that it will check for action names within the linked sprite file (in this case dive_mine/ticking_glow/ticking_glow.sprite), i.e. "idle" and "ticking".
@Rusty-Box Action-specific linked-sprites are already supported, so what I believe only needs to be done to support this is to be able to link sprites with custom default actions.
I modified your example, so by default it globally (for all actions) links the ticking-glow sprite with the action idle (since most actions seem to use it). Since only the last two actions use the ticking action from the sprite, it's declared again in a new linked-sprites block inside of them, with the same name (thus it will override the global ticking-glow linked sprite, which has the idle action).
At the end, the modified example looks like this:
(action
(name "left")
(fps 12.0)
(hitbox 14 19 32 32)
(images "left-0.png"
"left-1.png"
"left-2.png"
"left-3.png"
"left-4.png"
"left-5.png"
"left-6.png"
"left-7.png"
"left-8.png"
"left-9.png"
"left-10.png"
"left-11.png"))
(action
(name "right")
(fps 12.0)
(hitbox 14 19 32 32)
(mirror-action "left"))
(action
(name "iced-left")
(hitbox 5 8 32 32)
(images "left-0.png"))
(action
(name "iced-right")
(hitbox 5 8 32 32)
(mirror-action "iced-left"))
(action
(name "ticking-left")
(fps 15.0)
(hitbox 14 19 32 32)
(linked-sprites
(ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite" "ticking")
)
(images "ticking-0.png"
"ticking-1.png"
"ticking-2.png"
"ticking-3.png"
"ticking-4.png"
"ticking-5.png"
"ticking-6.png"
"ticking-7.png"
"ticking-8.png"
"ticking-9.png"))
(action
(name "ticking-right")
(fps 15.0)
(hitbox 14 19 32 32)
(linked-sprites
(ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite" "ticking")
)
(mirror-action "ticking-left"))
(linked-sprites
(ticking-glow "images/creatures/dive_mine/ticking_glow/ticking_glow.sprite" "idle")
)
@Rusty-Box Action-specific
linked-spritesare already supported, so what I believe only needs to be done to support this is to be able to link sprites with custom default actions.
Wait but Dive Mine's glow never changes. Rather is disappears when it should begins playing the ticking action, as of now. Is there just no way to define that right now? I'm so confused
Wait but Dive Mine's glow never changes. Rather is disappears when it should begins playing the ticking action, as of now. Is there just no way to define that right now? I'm so confused
As I mentioned in the beginning, it still has to be done, I just offered a way it could work.
Okay. Good to know. I thought I was going crazy here 😅 In that case I guess my only note would be that I feel like my proposal looks a bit better in terms of readbilty and having to type less but I ain't a coder so I don't wanna pretend I know better. Atleast I know now that I wasn't crazy, so that's nice :]
May be better in terms of readability, but would be more of a pain to implement. :D
(Oh, and this approach is also way more flexible, since you can also change the whole sprite, not just the action.)
Is it just me or is it not working? I updated Dive Mine's sprite file to look like you showed in this example here but it doesn't seem to work. The light keeps disapearing when you approach Dive Mine instead of changing the action of the linked sprite. Am I doing something wrong here?
Also the candle light doesn't seem to be rendered as a lightmap since you get a black box when you place it
Another thing: the lit object crashes the game if you place it