Opacity options
oranjoose

It appears that there is an in-editor option to change the opacity of Sprite components, and an in-code function to change the opacity of layers.

Correct me if I'm wrong, but there doesn't appear to be the inverse of the above set of options, specifically, the option to change the opacity of Sprites in the code, or the option to change the opacity of layers from the editor.

Maybe there could be a setOpacity function for Sprites, and a setOpacity function for SceneObjects, which sets the opacity for all the SceneObject's Sprite components in one call. This should probably also include the appropriate getOpacity functions, where the one for SceneObject could take a Sprite index argument, and if called without argument gets opacity of just the first Sprite component.

For changing the layer opacity in the editor, the field could maybe be per layer, among the other layer settings in the Properties panel when it is contextually "Scene Properties".

Just some ideas.

All 2 Comments
Gio

Controlling the opacity of layers from the editor shouldn't be too difficult to do - we can add that fairly quickly.

A setOpacity function for Sprites is a little trickier, because Sprites can have custom draw functions. When you create a sprite from the editor, it always uses the default draw function, there is no way to write a custom one directly from the visual editor, so it is not an issue to control opacity at that level. On the other hand, when you are doing things in code, you may have overridden the default draw function with your own, and we would not know what setOpacity would have to do to work with your custom draw function, which could be literaly anything.

At the moment you can achieve the same thing that setOpacity would do in a more convoluted way, by chaining the alpha draw function with your own

mySprite.setDrawFunction(wade.drawFunctions.alpha_(opacity, myCurrentDrawFunction));

I suppose we could add a setOpacity function with the caveat that calling it will reset the draw function of the sprite to the default one. That would work, and I'm not sure that it would be intuitive, but probably more intuitive than the current way of doing it.

oranjoose

Ah, I see. I personally would vote to have a setOpacity function, even if it resets the draw function, with a disclaimer in the documentation tooltip for the function in order to warn the developer that this would happen.

Thanks for the explanation.

Post a reply
Add Attachment
Submit Reply
Login to Reply