{SOLVED} Character Sprites Not Replacing

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.
Post Reply
Message
Author
User avatar
WhatNames
Newbie
Posts: 13
Joined: Mon Mar 21, 2016 8:03 pm
Completed: Jojo-a-GoGo
Projects: In the Storm (#ilujam)
Deviantart: whatnames2
Location: USA
Contact:

{SOLVED} Character Sprites Not Replacing

#1 Post by WhatNames »

So I was testing the first section of my latest game, and I'm finding that the sprites of my character aren't replacing after a certain spot? I checked the code and it's the same as it is above (where it's working), so I don't know why it's not working... :?:

Code: Select all

    show image "mae skeptic":
        xpos 0.15
    m "What am I, a lawyer?"
    show image "mae quiet":
        xpos 0.15
    m "Something more casual..."
    show image "mae skeptic":
        xpos 0.15
    m "Yo Ma and Eileen, I got some big ol' news for y'all!"
    show image "mae nerves":
        xpos 0.15
    m "Nope. Bad already."
    "I don't care how so far South I am, I am not a Southern belle."
    show image "mae quiet":
        xpos 0.15
Do you guts see anything I'm not? There's no error code or anything when it doesn't replace, it just won't show "mae quiet" for some reason.

Thanks for your help!
Last edited by WhatNames on Sat Jul 02, 2016 2:43 am, edited 1 time in total.

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: Character Sprites Not Replacing

#2 Post by 78909087 »

Try writing

show mae skeptic:
xpos 0.15
"-------"
show mae quiet:
xpos 0.15

Instead of defining them as images every line... As long as they're defined before the project with the names you use, it should work this way.
I am not friends with the sun.
Image

User avatar
78909087
Veteran
Posts: 277
Joined: Sat Aug 16, 2014 2:33 pm
Completed: Dungeons and Don't Do It, Wake Up
Projects: Lethe
IRC Nick: Pacermist
Contact:

Re: Character Sprites Not Replacing

#3 Post by 78909087 »

Make sure your indentation remains correct!
My phone won't allow me to use the code option in the editor, so I apologize.
I am not friends with the sun.
Image

User avatar
WhatNames
Newbie
Posts: 13
Joined: Mon Mar 21, 2016 8:03 pm
Completed: Jojo-a-GoGo
Projects: In the Storm (#ilujam)
Deviantart: whatnames2
Location: USA
Contact:

Re: Character Sprites Not Replacing

#4 Post by WhatNames »

78909087 wrote:Try writing

show mae skeptic:
xpos 0.15
"-------"
show mae quiet:
xpos 0.15

Instead of defining them as images every line... As long as they're defined before the project with the names you use, it should work this way.
Okay I tried it... When I input it like that, I get this error for each time I changed it from 'show image' to 'show':

Code: Select all

File "game/script.rpy", line 33: expected 'image_name_component' not found.
    show "mae quiet":
         ^
And for reference, my images are defined like this at the beginning:

Code: Select all

image mae nerves = "maenerves.png"
image mae quiet = "maequiet.png"
image mae realize = "maerealization.png"
image mae skeptic = "maeskeptical.png"
(Plus the images are all in the game folder, not image folder, so that can't be it either.)

It's only about halfway through that mae quiet isn't displayed (which is the code above). Before that it's fine. Any thoughts? :c
~beginner game creator and long time gamer~
✨ find me on deviantart @whatnames2 for game art ✨
>my games on itch<

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Character Sprites Not Replacing

#5 Post by chocoberrie »

Remove the quotation marks, so that you have:

Code: Select all

show mae quiet
instead of:

Code: Select all

show "mae quiet"
So your code would look like this:

Code: Select all

    show mae skeptic:
        xpos 0.15
    m "What am I, a lawyer?"
    show mae quiet:
        xpos 0.15
    m "Something more casual..."
    show mae skeptic:
        xpos 0.15
    m "Yo Ma and Eileen, I got some big ol' news for y'all!"
    show mae nerves:
        xpos 0.15
    m "Nope. Bad already."
    "I don't care how so far South I am, I am not a Southern belle."
    show mae quiet:
        xpos 0.15
Hope this helps! :)

User avatar
WhatNames
Newbie
Posts: 13
Joined: Mon Mar 21, 2016 8:03 pm
Completed: Jojo-a-GoGo
Projects: In the Storm (#ilujam)
Deviantart: whatnames2
Location: USA
Contact:

Re: Character Sprites Not Replacing

#6 Post by WhatNames »

Okay so one thing that works to make the next piece show up is this:

Code: Select all

show image "mae skeptic" at midleft
    m "What am I, a lawyer?"
    hide image "mae skeptic"
    show image "mae quiet" at midleft
This seems to fix the issue, but that's still odd and I'd prefer to just have it replace the other image!
(I also defined midleft so I wouldn't have to retype xpos 0.15 each time.)
chocoberrie wrote:Remove the quotation marks, so that you have:

Code: Select all

show mae quiet
instead of:

Code: Select all

show "mae quiet"
So your code would look like this:

Code: Select all

    show mae skeptic:
        xpos 0.15
    m "What am I, a lawyer?"
    show mae quiet:
        xpos 0.15
    m "Something more casual..."
    show mae skeptic:
        xpos 0.15
    m "Yo Ma and Eileen, I got some big ol' news for y'all!"
    show mae nerves:
        xpos 0.15
    m "Nope. Bad already."
    "I don't care how so far South I am, I am not a Southern belle."
    show mae quiet:
        xpos 0.15
Hope this helps! :)
I attempted this as well, and I got a new error:

Code: Select all

File "game/script.rpy", line 30: Line is indented, but the preceding show statement statement does not expect a block. Please check this line's indentation.
    xpos 0.15
    ^
Thank you anyway!
~beginner game creator and long time gamer~
✨ find me on deviantart @whatnames2 for game art ✨
>my games on itch<

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Character Sprites Not Replacing

#7 Post by chocoberrie »

Instead of using xpos and ypos to position each individual side image, you can use show_side_image along with xalign and yalign to position all the side images for a character before the rest of the script, like this:

Code: Select all

image side e = ("Eileen.png")

define e = Character(show_side_image=Image("Eileen.png", xalign=0.0, yalign=1.0))
With the above code, you can define a side image and its position on the screen. xalign=0.0 and yalign=1.0 would put the side image at the bottom left corner of the screen.

Here's an example script that shows how you can define more than one side image, if you have sprite side images with emotions (e.g. a side image for happy, a side image for sad, etc.):

Code: Select all

# You can place the script of your game in this file.

# Declare images below this line, using the image statement.
# eg. image eileen happy = "eileen_happy.png"

# Declare characters used by this game.

image side c_curious = "cside_curious.png"
image side c_happy = "cside_happy.png"
image side c_embarassed = "cside_embarassed.png"

define c_curious = Character(show_side_image=Image("cside_curious.png", xalign=0.0, yalign=1.0))
define c_happy = Character(show_side_image=Image("cside_happy.png", xalign=0.0, yalign=1.0))
define c_embarassed = Character(show_side_image=Image("cside_embarassed.png", xalign=0.0, yalign=1.0))

# The game starts here.
label start:
    c_curious "You've created a new Ren'Py game."

    c_happy "Once you add a story, pictures, and music, you can release it to the world!"

    return
Each side image is defined as a character, which is kinda tedious to code, but it does work! You would have to be careful how you call the side images in the script.

In order to keep the side images from appearing on top of the text in the dialogue box at the bottom of the screen, find the following code in options.rpy:

Code: Select all

    #########################################
    ## These settings let you customize the window containing the
    ## dialogue and narration, by replacing it with an image.

    ## The background of the window. In a Frame, the two numbers
    ## are the size of the left/right and top/bottom borders,
    ## respectively.

    # style.window.background = Frame("frame.png", 12, 12)

    ## Margin is space surrounding the window, where the background
    ## is not drawn.

    # style.window.left_margin = 6
    # style.window.right_margin = 6
    # style.window.top_margin = 6
    # style.window.bottom_margin = 6

    ## Padding is space inside the window, where the background is
    ## drawn.

    # style.window.left_padding = 6
    # style.window.right_padding = 6
    # style.window.top_padding = 6
    # style.window.bottom_padding = 6

    ## This is the minimum height of the window, including the margins
    ## and padding.

    # style.window.yminimum = 250
You need to do two things: 1) remove the # sign before style.window.left_padding and fix the indentation, and 2) adjust the number after style.window.left_padding to the width, in pixels, of the side image. So if my side image is 200 pixels wide, my code would look like this:

Code: Select all

    #########################################
    ## These settings let you customize the window containing the
    ## dialogue and narration, by replacing it with an image.

    ## The background of the window. In a Frame, the two numbers
    ## are the size of the left/right and top/bottom borders,
    ## respectively.

    # style.window.background = Frame("frame.png", 12, 12)

    ## Margin is space surrounding the window, where the background
    ## is not drawn.

    # style.window.left_margin = 6
    # style.window.right_margin = 6
    # style.window.top_margin = 6
    # style.window.bottom_margin = 6

    ## Padding is space inside the window, where the background is
    ## drawn.

    style.window.left_padding = 200
    # style.window.right_padding = 6
    # style.window.top_padding = 6
    # style.window.bottom_padding = 6

    ## This is the minimum height of the window, including the margins
    ## and padding.

    # style.window.yminimum = 250

User avatar
WhatNames
Newbie
Posts: 13
Joined: Mon Mar 21, 2016 8:03 pm
Completed: Jojo-a-GoGo
Projects: In the Storm (#ilujam)
Deviantart: whatnames2
Location: USA
Contact:

Re: Character Sprites Not Replacing

#8 Post by WhatNames »

chocoberrie wrote:Instead of using xpos and ypos to position each individual side image, you can use show_side_image along with xalign and yalign to position all the side images for a character before the rest of the script, like this:
This is informative, but not quite the problem I'm trying to fix, sorry! I think I may have written that last post in a confusing order...

I used this code to define the "midleft" position and that was just so I wouldn't have to type xpos 0.15 each time.

Code: Select all

init:
    $ midleft = Position(xpos=0.15, xanchor='left')
When I go and take out the quotes, I get this error:

Code: Select all

File "game/script.rpy", line 36: end of line expected.
    show image mae -> quiet at midleft
                   ^
I can't seem to find a way beyond showing and hiding each sprite to make the next one show up in game. Does anything other than my quotes look out of place?

This is where they stop showing up:

Code: Select all

    show image "mae nerves" at midleft
    m "Nope. Bad already."
    show image "mae realize" at midleft
That is, as long as I put:

Code: Select all

    show image "mae skeptic" at midleft
    m "What am I, a lawyer?"
    hide image "mae skeptic"
Hiding each image usually makes the next one show up, but I'm trying to avoid that since it seems to be breaking after that point...
~beginner game creator and long time gamer~
✨ find me on deviantart @whatnames2 for game art ✨
>my games on itch<

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Character Sprites Not Replacing

#9 Post by chocoberrie »

Hmmm... I'm not sure why I got the impression that you're trying to use side images... Sorry about the confusion XD

You're trying to show regular, full size sprites, one after the other, makes sense!

How about this:

Code: Select all

define c = Character("Celeste", image="celeste")

image celeste happy = "sprites/celeste happy.png"
image celeste curious = "sprites/celeste curious.png"

# The game starts here.
label start:
    show celeste curious
    c "You've created a new Ren'Py game."

    show celeste happy
    c "Once you add a story, pictures, and music, you can release it to the world!"

    return
Defining a character that way makes Ren'Py find all images defined with the variable in quotes after image= so that you don't have to keep defining them explicitly in the rest of the script.

Also, using the show statement makes the sprite appear, as you know. I didn't have to use the hide statement to make the previous sprite disappear before showing another one; it disappears on its own.

Does this help? :?

User avatar
WhatNames
Newbie
Posts: 13
Joined: Mon Mar 21, 2016 8:03 pm
Completed: Jojo-a-GoGo
Projects: In the Storm (#ilujam)
Deviantart: whatnames2
Location: USA
Contact:

Re: Character Sprites Not Replacing

#10 Post by WhatNames »

So before you posted that last reply, I attempted to hide each image I put onscreen just to see if that would fix it. Now, when I press start on the home menu, before I even have put any "show image" besides the background, "mae skeptic" is onscreen. I have no idea why or how she got there, but tada! There she is!

("mae skeptic" isn't even the first mae sprite I show...)

I tried taking out the quotes around each image name and I got this for each one other than the first one:

Code: Select all

File "game/script.rpy", line 36: end of line expected.
    show image mae quiet at midleft
                   ^
When I take out only the first show image "mae realize" quotes, it starts out fine, but then completely ignores any command to show "mae quiet" and will completely skip over some of the other commands to show other expressions. I have no idea how or why it's doing this at this point!
~beginner game creator and long time gamer~
✨ find me on deviantart @whatnames2 for game art ✨
>my games on itch<

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Character Sprites Not Replacing

#11 Post by chocoberrie »

Gosh! That's quite confusing!

I found a solution to your positioning issue! Try defining the xpos=0.15 position with a variable, like this:

Code: Select all

init:
    $ cpos = Position(xpos=0.15)
This bit goes in the same block as the character definitions, at the top of the script, like this:

Code: Select all

init:
    $ cpos = Position(xpos=0.15)
    define c = Character("Celeste", image="celeste")

    image celeste happy = "sprites/celeste happy.png"
    image celeste curious = "sprites/celeste curious.png"
So in the script, if I want my sprite to show up at that position, I'd write:

Code: Select all

    show celeste curious at cpos
Since you want your sprite to be at xpos=0.15 all the time:

Code: Select all

init:
    $ maepos = Position(xpos=0.15)
    define m =Character() <---- your character definition here

    image mae nerves = "maenerves.png"
    image mae quiet = "maequiet.png"
    image mae realize = "maerealization.png"
    image mae skeptic = "maeskeptical.png"

label start:

    show mae skeptic at maepos
    m "What am I, a lawyer?"
    show mae quiet at maepos
    m "Something more casual..."
    show mae skeptic at maepos
    m "Yo Ma and Eileen, I got some big ol' news for y'all!"
    show mae nerves at maepos
    m "Nope. Bad already."
    "I don't care how so far South I am, I am not a Southern belle."
    show mae quiet at maepos
Of course, you can use any label, it doesn't have to be maepos. Just don't put any spaces in it! Hope this helps :)

User avatar
WhatNames
Newbie
Posts: 13
Joined: Mon Mar 21, 2016 8:03 pm
Completed: Jojo-a-GoGo
Projects: In the Storm (#ilujam)
Deviantart: whatnames2
Location: USA
Contact:

Re: Character Sprites Not Replacing

#12 Post by WhatNames »

Ack! I've got the positioning down; I defined it like this:

Code: Select all

init:
    $ midleft = Position(xpos=0.15, xanchor='left')
And that's working very well, thank goodness!

Unfortunately, it still won't show my character as I'm telling it to, and is completely ignoring "mae quiet" along with a few other seemingly random commands.

Code: Select all

label start:
    scene bg maeroom1
    play music "heavy_rain.ogg"    
    "The rain is pouring down onto the roof of my house."
    "It's been like that for an hour or so."
    "Ma and Eileen called me earlier."
    "They said it was storming so bad where they were that they wouldn't be able to make it home tonight, maybe even tomorrow."
    "I guess that comes with being the vet for all the local ranches."
    show mae realize at midleft
    with dissolve
    m "Long drives..."
    "I shift my laptop over to my other leg and rearrange the blankets on my bed."
    show image "mae quiet" at midleft
    m "At least it gives me more time to figure out what to tell them."
    "I've been working on and off on my 'speech' for a few days now."
    "And by working I mean wildly avoiding and procrastinating about it."
    show image "mae nerves" at midleft
    m "Why is this so hard?"
    "I lean my head against the wall."
    "Sadly, it doesn't offer any help."
    show image "mae quiet" at midleft
    m "Okay, one more time..."
    play sound "keyboard.mp3"
    m "Dear Ma and Eileen. It has been my intention for a while to inform you..."
    stop sound
    "..."
    show image "mae skeptic" at midleft
    m "What am I, a lawyer?"
    show image "mae quiet" at midleft
    m "Something more casual..."
    show image "mae skeptic" at midleft
    play sound "keyboard.mp3"
    m "Yo Ma and Eileen, I got some big ol' news for y'all!"
    stop sound
    show image "mae nerves" at midleft
    m "Nope. Bad already."
    show image "mae realize" at midleft
    "I don't care how so far South I am, I am not a Southern belle."
    show image "mae quiet" at midleft
    "I sigh."
    m "Let's try this again."
That's all the code up to where things start getting wonky and not showing up...
~beginner game creator and long time gamer~
✨ find me on deviantart @whatnames2 for game art ✨
>my games on itch<

User avatar
chocoberrie
Veteran
Posts: 254
Joined: Wed Jun 19, 2013 10:34 pm
Projects: Marshmallow Days
Contact:

Re: Character Sprites Not Replacing

#13 Post by chocoberrie »

Hmmm... Well, you seem to be making images show differently, coding-wise.

You have show mae realize at midleft early on in your script, and then every other image statement after that is show image "mae _____". Maybe this is the source of the issue?

Try using the first show statement (e.g. show mae quiet at midleft) instead of putting the image and quotations bit. You got the positioning to work, which is good! :)

User avatar
WhatNames
Newbie
Posts: 13
Joined: Mon Mar 21, 2016 8:03 pm
Completed: Jojo-a-GoGo
Projects: In the Storm (#ilujam)
Deviantart: whatnames2
Location: USA
Contact:

Re: Character Sprites Not Replacing

#14 Post by WhatNames »

IT WORKED
OH THANK GOODNESS
THANK YOU
I tried running it and it didn't work at first, but I think I missed one or two that had show image "blahs" in them but once I found and changed them it works like a dream.
Thank you so much! c:
~beginner game creator and long time gamer~
✨ find me on deviantart @whatnames2 for game art ✨
>my games on itch<

Post Reply

Who is online

Users browsing this forum: No registered users