Page 1 of 1

The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 5:59 am
by swampie2
So we've been directing some of our scenes and having some troubles with some code:

Code: Select all

image CHAR Happy2 = im.Flip(im.FactorScale("images/Sprites/Side Characters/CHAR/CHAR_P1_E2.png", 0.66), horizontal=True)
show CHAR Happy2:
  offscreenright
  alpha 0.0 xalign 0.8 yalign 1
  easein 1.0 xalign 0.7 yalign 1 alpha 1
So this code has our sprite fade in while moving toward their position from offscreen, however changing the yalign values does nothing, these sprites default to a yalign of .5 even when told otherwise, causing them to float.

We tried simplifying the code to try and find the problem like so:

Code: Select all

image CHAR Happy2 = im.FactorScale("images/Sprites/Side Characters/CHAR/CHAR_P1_E2.png", 0.66)
show CHAR Happy2:
  xalign 0.7 yalign 1
Or altering our syntax

Code: Select all

image CHAR Happy2 = im.Flip(im.FactorScale("images/Sprites/Side Characters/CHAR /CHAR _P1_E2.png", 0.66), horizontal=True)
show CHAR Happy2 :
  offscreenright
  alpha 0.0 align (0.8, 0.1)
  easein 1.0 align (0.7, 0.1) alpha 1
But our sprite still spawns in at yalign 0.5, no matter what the yalign is defined as when we call it. We've had this problem with multiple different sprites across multiple different scenes across multiple computers. What are we doing wrong?

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 6:30 am
by helcries
Have you tried using the following code?

Code: Select all

show CHAR Happy2 at left with fade

show CHAR Happy2 at right with dissolve
It's about the easiest way I know to make sure that the sprites are not in the center of the screen.

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 6:40 am
by swampie2
helcries wrote:Have you tried using the following code?
We'd still like control over exact values so we can position our characters and fadeins precisely, it doesn't look like this solution will allow for that.

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 6:56 am
by helcries
I THINK you can program a custom location like you can do custom transitions, but again its something that I haven't tried yet, so I'm not 100% sure.

https://www.renpy.org/doc/html/transforms.html

Thats the link I check when I am looking up info in transforms and image placement, it has a link on the bottom that goes into ATL which might give you some better help than I was.

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 7:21 am
by swampie2
I'm afraid this doesn't really solve my problem. We're using custom positions, but renpy refuses to read the yalign value.

This code has worked fine for other sprites and even this exact sprite in an earlier script, but for some reason, in this use of the code + a few others, it refuses to read the yalign, ypos or yanchor and instead defaults to 0.5.

I'm not asking how to position the sprite, I'm asking why renpy won't read the value I'm giving it when I'm telling it where it's position is.

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 7:24 am
by Imperf3kt
According to the documentation, the "offscreenright" defaults to the bottom of the screen.
Judging from this, does your sprite have any transparent space below the actual image?
for example:
REALLYSHITTYSTICKMAN.png
REALLYSHITTYSTICKMAN.png (2.75 KiB) Viewed 1653 times

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 7:29 am
by Mammon
First off: loving the title. Actually opened this thinking it was a WiP thread. (That can happen when you browse the lastest topics rather than a particular section.)

I'm not a talented coder in the least so I might not be of help here, but two possible solutions:
-Why yalign, shouldn't you set x to 0.0 to get a character to the bottom of the screen? That's what I did and it worked. Now I'm wondering WHY it worked...
-What I used to get my sprites at a specific locations:

Code: Select all

#outside of script, inside of script.rpy:
transform abd:
     xalign 0.0, yalign 0.8
#in script:
show me at abd
me 'And now I'm at the location "abd" instead of the standard location.'

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 8:09 am
by swampie2
Imperf3kt wrote:does your sprite have any transparent space below the actual image?
The sprite has space around the top and sides, but the bottom of the image ends at the bottom of the sprite.
Mammon wrote:Actually opened this thinking it was a WiP thread.
An interesting idea!
Mammon wrote:shouldn't you set x to 0.0 to get a character to the bottom of the screen?
This is true, but I've tried changing the yalign value from 10000 to -10000 and I'm getting no difference, always the default 0.5

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 8:25 am
by Mammon
Swampie wrote:
Mammon wrote:shouldn't you set x to 0.0 to get a character to the bottom of the screen?
This is true, but I've tried changing the yalign value from 10000 to -10000 and I'm getting no difference, always the default 0.5
No, I mean change the xalign instead of the yalign? Even though that shouldn't solve the problem logically, the transform that I quoted in my last post is directly from my game, and the characters are solidly standing on the ground rather than floating even though y is set at 0.8

So your code as seen below, (which actually seems to have an yalign of 1 rather than 0,) might stop floating when you set the xalign to 0.0, which worked for my sprites.

Code: Select all

image CHAR Happy2 = im.Flip(im.FactorScale("images/Sprites/Side Characters/CHAR/CHAR_P1_E2.png", 0.66), horizontal=True)
show CHAR Happy2:
  offscreenright
  alpha 0.0 xalign 0.8 yalign 1
  easein 1.0 xalign 0.7 yalign 1 alpha 1

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 8:33 am
by swampie2
No dice, this just moves the character to the far left of the screen, still in the middle height wise.

Code: Select all

image CHAR Happy2 = im.Flip(im.FactorScale("images/Sprites/Side Characters/CHAR/CHAR_P1_E2.png", 0.66), horizontal=True)
show CHAR Happy2 :
  offscreenright
  alpha 0.0 align (0.8, 0)
  easein 1.0 align (0.0, 0) alpha 1

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 8:36 am
by xela
Post the sprite you're having an issue with and code you're using, stuff like this is used in almost every game and cannot be broken in a way your suggest. You prolly don't understand difference in behavior when using floats and ints as align values or somehow setup some weird outer container that messes up the alignment.

alpha 0.0 xalign 0.8 yalign 1

this for example aligns to the top of the screen.

alpha 0.0 xalign 0.8 yalign 1.0

this aligns to the bottom of the screen and etc...

It gets increasingly more confusing if you use mix floats and integers within the same set of instructions.

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 8:41 am
by swampie2
xela wrote:alpha 0.0 xalign 0.8 yalign 1

this for example aligns to the top of the screen.

alpha 0.0 xalign 0.8 yalign 1.0

this aligns to the bottom of the screen and etc...
You're beautiful, this solved the problem. Thanks a bunch guys!

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 9:37 am
by Scribbles
OMG this fixed an issue I was having too! I was using ypos instead of yalign and some of my sprites would be low and others would be high and I had no idea what was going on lol

Re: The curse of the unexplained flying girls

Posted: Thu Jan 26, 2017 9:52 am
by xela
It's not just you, this issue is shared by a whole lot of people... I disagree with the concept of sharing floats and ints for positional argument, it's a lot more trouble than it's worth.

I have found that a good way of thinking about it may be:

pos/offset: ALWAYS USE INTS.
align/anchor: ALWAYS USE FLOATS.

I've been sticking with this setup for as long as I can remember and never had any problems. Divination from that caused so many issues for so many people :( To make matters worse, if you use both in the same set of instruction or sometimes even when passing instructions to new ones, chances are that you will never see your sprite ever again cause Ren'Py would convert everything to floats as it pleases and send your sprite flying to the moon :)