The Dink Network

Changing a sprite's hardbox

February 21st 2017, 05:56 PM
Is there an easy way to change the size of a sprite's hardbox?

(During the game using DinkC, not in the editor)
February 21st 2017, 06:35 PM
Peasant Male Japan xbox steam bloop
Responsible for making things not look like ass 
Afaik there's no easy way to alter the size of the hardbox from scripting. Although, thinking about it, you *might* be able to initialize a sprite with different parameters. You'd likely have to redraw the screen after that though.

Frankly, the easiest way would be to use another sprite with the hardbox you want to have already there, and then enable/disable the hardboxes when needed.
February 23rd 2017, 12:55 PM
Peasant Male Belgium
LeprochaUn's approach would work. You can attach the second sprite as a shadow of the first, though it lags behind a little bit. If you know exactly when it changes its hardbox, you can also manually position the second sprite when the time comes.
February 24th 2017, 05:47 AM
Bard Male Finland bloop
cigarette bonca 
Init() should work, shouldn't it? I think you can even directly use load_sequence_now from a script (and probably set_sprite_info), although I don't think anyone does that, so it's largely untested whether there are any problems.
February 26th 2017, 09:32 AM
Hmm yes I guess Init() is the obvious one. I was thinking the simplest solution would be just to have a duplicate of every sprite I need with a different hardbox, but loading it on the fly would be better as then the sequence/frame numbers won't change.

It's for Solitaire in Broken Windows, playing around with that again trying to get it to work fully... It turns out that if you have several sprites on top of each other and click on them with the mouse, the one that was created first is the one that's actually "clicked" (ie only that sprite's click procedure is run). Nothing to do with depth que which I was expecting (and hoping for!).
Which is a pain when working with stacks of overlapping cards, hence the need for smaller hardboxes...
February 26th 2017, 09:57 AM
Bother, on second thoughts load_sequence will affect the entire sequence, not a single frame, so no use here.

On third thoughts, scratcher mentioned set_sprite_info... time for some experimenting.
March 3rd 2017, 03:48 AM
Peasant Netherlands
Never be afraid to ask, but don't demand an answer 
Yes, this can be done; it is the trick that magicman used to make this work.

Note the other part of the trick, which you should not be surprised by: those changes survive through load_game() and restart_game().