Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
I've got a small sprite on the screen which I'm masking in certain areas of the screen with a screen-sized separate mask image using AlphaMask(). But, how can I then animate the small sprite to move around the screen without changing the position of the screen mask image?
Then the entire AlphaMask image will of course move. In short, how is it possible to access these two AlphaMask components separately for the sake of animation?
Last edited by computistxyz on Mon Oct 12, 2015 9:47 am, edited 1 time in total.
Okay, you'll have to do some rethinking as to how you've coded it. The point of AlphaMask is to take an image, a mask, and to spit back one image - not something with multiple components.
If you need them to be separate components, you have to program it *as separate components*.
How to do it exactly? I don't know how you're planning on having it work in the long run, so I can't answer that.
Onishion wrote:I'd like to know an easy way to do this as well, but there might be a cheap workaround to it, if this would work for your project.
1. Take the background you're using.
2. Duplicate that background, and display the second copy of it on a layer above the object you want to move around.
3. Alpha that second "background" to have holes wherever you want to see your object, and be opaque where you want the object invisible.
That way, it should provide the effect you're describing.
That's an interesting workaround. However, in my case, there's a number of different backgrounds and animated sprites all preexisting behind this masked animated element, so it's not as simple as duplicating and masking a single background...
That's an interesting workaround. However, in my case, there's a number of different backgrounds and animated sprites all preexisting behind this masked animated element, so it's not as simple as duplicating and masking a single background...
Hmm. Well I haven't messed with the alpha thing much, so I'm not sure if this would work, but it might.
1. Take the background, and make a composite image that is the background AND all images that you want to be behind the moving object.
2. Duplicate that image, use it as the foreground with the alpha thing going on, with the moving object sandwiched between.
I have no idea whether parts of that would fail, but it might work.
image sprite:
"sprite.png"
#Animation data here
image maskedsprite:
AlphaMask("sprite", "mask.png")
Which works as expected. However, whilst transforms such as zoom and rotate can be applied and even animated with linear in that preliminary image definition, positional transforms (namely, pos and offset) used in exactly same way have no effect. I'm not entirely sure as to why this is - perhaps someone with a deeper understanding of the AlphaMask function could offer an explanation for this behaviour?
Onishion wrote:
1. Take the background, and make a composite image that is the background AND all images that you want to be behind the moving object.
2. Duplicate that image, use it as the foreground with the alpha thing going on, with the moving object sandwiched between.
I can imagine that working; the only problem is that this masked animation occurs quite regularly at various points, with no particular way of knowing what else may or may not be present behind it on the screen in any given instance...
Which works as expected. However, whilst transforms such as zoom and rotate can be applied and even animated with linear in that preliminary image definition, positional transforms (namely, pos and offset) used in exactly same way have no effect. I'm not entirely sure as to why this is - perhaps someone with a deeper understanding of the AlphaMask function could offer an explanation for this behaviour?
I know I've run into similar issues with LiveComposite. If I try to insert animated objects into Live Composites, they sometimes don't work right, in exactly that way. Certain image compositing mechanisms seem to be squirly when it comes to positional data.
I can imagine that working; the only problem is that this masked animation occurs quite regularly at various points, with no particular way of knowing what else may or may not be present behind it on the screen in any given instance...
nyaatrap wrote:It looks you want to mask a layer, not an image. It can be done when you show an image on a higher layer then apply an alpha transition on the layer.
init python:
config.layers = ["master", "transient", "screens", "overlay", "sprites"]
define spriteMask = AlphaDissolve("mask.png", delay=1.1, alpha=True)
image sprite:
#blah blah animation goes here
label start:
show layer sprites at spriteMask
show sprite onlayer sprites
The actual masking effect works correctly in tandem with the animations when tested separately. However, upon the show statements, I get the following critical error:
TypeError: __init__() got multiple values for keyword argument 'delay'
The fact the masking transformation is actually a transition strikes me as odd; I've just thrown in a suitable value of 1.1 for 'delay'. But, it doesn't seem to like this.
nyaatrap wrote:It looks you want to mask a layer, not an image. It can be done when you show an image on a higher layer then apply an alpha transition on the layer.
init python:
config.layers = ["master", "transient", "screens", "overlay", "sprites"]
define spriteMask = AlphaDissolve("mask.png", delay=1.1, alpha=True)
image sprite:
#blah blah animation goes here
label start:
show layer sprites at spriteMask
show sprite onlayer sprites
The actual masking effect works correctly in tandem with the animations when tested separately. However, upon the show statements, I get the following critical error:
TypeError: __init__() got multiple values for keyword argument 'delay'
The fact the masking transformation is actually a transition strikes me as odd; I've just thrown in a suitable value of 1.1 for 'delay'. But, it doesn't seem to like this.
Bumping for increasing urgency. Could someone with a more in-depth knowledge of layers/AlphaDissolve perhaps have any explanation for this situation?
So, the problem is that you're trying to use AlphaDissolve, but it's a Transition, not a Transform - and so won't work. I think want you probably want is an AlphaMask transform. That doesn't exist in the form you want, but we can easily create one.
PyTom wrote:So, the problem is that you're trying to use AlphaDissolve, but it's a Transition, not a Transform - and so won't work. I think want you probably want is an AlphaMask transform. That doesn't exist in the form you want, but we can easily create one.