Is it possible for a contraption to change its own size? I'm creating an animated sprite contraption that gets the sprite width and height from its attributes, and then shows an animation taken from a sprite sheet card.
I tried to do
me.size:(sprite_width.text,sprite_height.text)
on the view event, but it doesn't do anything when the contraption is running on a card (it does change its size when running inside the prototype view). I'm saving the state in hidden fields inside the prototype. Here's the whole script:
on get_spritesheet do sprite_sheet_card.text end on set_spritesheet x do sprite_sheet_card.text: x end on get_frames do frames.text+0 end on set_frames x do frames.text:x end on get_sprite_width do sprite_width.text+0 end on set_sprite_width x do sprite_width.text:x end on get_sprite_height do sprite_height.text+0 end on set_sprite_height x do sprite_height.text:x end on get_fps do fps.text+0 end on set_fps x do fps.text:x end on get_loop do loop.text+0 end on set_loop x do loop.text:x end on get_current_frame do current_frame.text+0 end on set_current_frame x do current_frame.text:x end on view do me.size:(sprite_width.text,sprite_height.text) c:deck.cards[sprite_sheet_card.text] w:c.image.size[0] h:c.image.size[1] f:current_frame.text i:c.image me.image.paste[i.copy[(w%sprite_width.text*floor f,floor sprite_width.text*floor f / w) (sprite_width.text,sprite_height.text)]] current_frame.text:frames.text%f+fps.text*1/60 end
The only thing I'm missing is for the contraption to resize itself to fit the configured sprite size.
EDIT: I made the prototype resizable, and it's working now. The problem is that the state is shared between different instances of the same prototype, so I'm obviously doing something very wrong here.