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.
-
computistxyz
- Regular
- Posts: 58
- Joined: Thu Jul 10, 2014 8:35 am
- Github: sjgriffiths
- Location: Coventry/Norwich, UK
-
Contact:
#1
Post
by computistxyz » Fri Sep 25, 2015 9:11 am
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?
If I simply use:
Code: Select all
image spriteMasked:
AlphaMask("sprite.png", "mask.png")
pos (0, 0)
linear 2.0 pos (500, 500)
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.
-
orz
- Regular
- Posts: 126
- Joined: Tue Apr 21, 2015 10:19 pm
-
Contact:
#2
Post
by orz » Fri Sep 25, 2015 12:11 pm
Why not make the image a composite (using LiveComposite) and just moving that around?
-
computistxyz
- Regular
- Posts: 58
- Joined: Thu Jul 10, 2014 8:35 am
- Github: sjgriffiths
- Location: Coventry/Norwich, UK
-
Contact:
#3
Post
by computistxyz » Fri Sep 25, 2015 12:25 pm
orz wrote:Why not make the image a composite (using LiveComposite) and just moving that around?
I'm not sure I understand how that would help. Do you mean putting the small sprite in a LiveComposite, such that:
Code: Select all
AlphaMask(LiveComposite( (1920,1080), (0,0), "sprite.png") , "mask.png")
Or put the entire AlphaMask object into a LiveComposite?
-
orz
- Regular
- Posts: 126
- Joined: Tue Apr 21, 2015 10:19 pm
-
Contact:
#4
Post
by orz » Fri Sep 25, 2015 12:34 pm
I misunderstood your problem - skimmed too fast. Thought you were saying only one part was moving when you wanted all of it to move, not the opposite.
I'll have to do some reading on what exactly AlphaMask is and does.
-
orz
- Regular
- Posts: 126
- Joined: Tue Apr 21, 2015 10:19 pm
-
Contact:
#5
Post
by orz » Fri Sep 25, 2015 5:41 pm
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
- Veteran
- Posts: 295
- Joined: Mon Apr 20, 2015 10:36 am
-
Contact:
#6
Post
by Onishion » Fri Sep 25, 2015 6:16 pm
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.
-
computistxyz
- Regular
- Posts: 58
- Joined: Thu Jul 10, 2014 8:35 am
- Github: sjgriffiths
- Location: Coventry/Norwich, UK
-
Contact:
#7
Post
by computistxyz » Fri Sep 25, 2015 9:28 pm
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...
-
Onishion
- Veteran
- Posts: 295
- Joined: Mon Apr 20, 2015 10:36 am
-
Contact:
#8
Post
by Onishion » Fri Sep 25, 2015 10:12 pm
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.
-
computistxyz
- Regular
- Posts: 58
- Joined: Thu Jul 10, 2014 8:35 am
- Github: sjgriffiths
- Location: Coventry/Norwich, UK
-
Contact:
#9
Post
by computistxyz » Mon Sep 28, 2015 8:54 am
I've attempted a slightly different approach by defining the sprite image separately like so:
Code: Select all
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...
-
Onishion
- Veteran
- Posts: 295
- Joined: Mon Apr 20, 2015 10:36 am
-
Contact:
#10
Post
by Onishion » Tue Sep 29, 2015 12:14 am
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...
Hmm, yeah, it would get complicated.
-
nyaatrap
- Crawling Chaos
- Posts: 1824
- Joined: Mon Feb 13, 2012 5:37 am
- Location: Kimashi Tower, Japan
-
Contact:
#11
Post
by nyaatrap » Tue Sep 29, 2015 1:42 am
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.
-
computistxyz
- Regular
- Posts: 58
- Joined: Thu Jul 10, 2014 8:35 am
- Github: sjgriffiths
- Location: Coventry/Norwich, UK
-
Contact:
#12
Post
by computistxyz » Tue Sep 29, 2015 9:57 am
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.
That sounds like it could work!
I've gotten this so far:
Code: Select all
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:
Code: Select all
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.
-
computistxyz
- Regular
- Posts: 58
- Joined: Thu Jul 10, 2014 8:35 am
- Github: sjgriffiths
- Location: Coventry/Norwich, UK
-
Contact:
#13
Post
by computistxyz » Tue Oct 06, 2015 5:19 am
TARDISam24 wrote: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.
That sounds like it could work!
I've gotten this so far:
Code: Select all
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:
Code: Select all
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?
-
PyTom
- Ren'Py Creator
- Posts: 15893
- Joined: Mon Feb 02, 2004 10:58 am
- Completed: Moonlight Walks
- Projects: Ren'Py
- IRC Nick: renpytom
- Github: renpytom
- itch: renpytom
- Location: Kings Park, NY
-
Contact:
#14
Post
by PyTom » Wed Oct 07, 2015 12:03 am
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.
Code: Select all
init python:
def SpriteMask(d):
return AlphaMask(d, "mask.png")
show layer sprites at SpriteMask
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama •
https://www.patreon.com/renpytom
-
computistxyz
- Regular
- Posts: 58
- Joined: Thu Jul 10, 2014 8:35 am
- Github: sjgriffiths
- Location: Coventry/Norwich, UK
-
Contact:
#15
Post
by computistxyz » Mon Oct 12, 2015 9:47 am
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.
Code: Select all
init python:
def SpriteMask(d):
return AlphaMask(d, "mask.png")
show layer sprites at SpriteMask
Brilliant - that's working perfectly, thanks!
Users browsing this forum: Hojoo