[solved] How do you make a bouncing "progress" indicator?

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
wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

[solved] How do you make a bouncing "progress" indicator?

#1 Post by wizzardx »

I've been trying to research this, but no luck yet.

Basically, I want a type of "icon" to appear near the bottom-left of the text area, when it's time for the user to proceed.

I can make a static icon appear there, like this:

Code: Select all

proceed = Image('misc/ui/proceed.png', xalign=0.95, yalign=0.96)

define std = Character(None,
    ctc=proceed, ctc_position='fixed',
    who_outlines=[(1, "#000080")])

define aoto      = Character('Aoto', std)

script:
    aoto "Hello"
Then when after the "Aoto" character says "Hello", the image "proceed.png" will show at the bottom lower-left of the screen, where I want it to.

However, I now want to give that icon a small "bouncing up and down" effect.

The most obvious way to do this seems to be to have the position of the "proceed" image actually be an anim.Move object, with the "bounce" and "repeat" parameters set to True.

However, in the initialization of the "proceed" image, I don't know how to make the Image's "position properties" be set to an "anim.Move" object.

I researched this some more, and found PyTom's advice to another poster over here:

http://lemmasoft.renai.us/forums/viewto ... ?f=8&t=890

That was actually advice for working around a bug in 2006, but from there, I see that you can create an image object as a "child" of a position object. Then if you show the "position" object, it automatically places the child image.

I tried extending that example, by using anim.Move instead of Position, but hit a problem.

This works for me:

Code: Select all

define my_move = Position(xalign=0.95, yalign=0.96)
define proceed = my_move(im.Image('misc/ui/proceed.png'))
But this doesn't work:

Code: Select all

define my_move = Move(left, right, repeat=True, bounce=True)
define proceed = my_move(im.Image('misc/ui/proceed.png'))
When I try that, I get this error:

Code: Select all

Full traceback:
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/execution.py", line 261, in run
    node.execute()
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/ast.py", line 1456, in execute
    value = renpy.python.py_eval_bytecode(self.code.bytecode)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/python.py", line 998, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 61, in <module>
    
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/curry.py", line 38, in __call__
    **dict(self.kwargs.items() + kwargs.items()))
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/motion.py", line 1047, in Move
    return Motion(Interpolate(startpos, endpos),
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/motion.py", line 942, in __init__
    if len(start) != len(end):
TypeError: object of type 'ATLTransform' has no len()

While executing init code:
  File "game/script.rpy", line 63, in script
    define proceed = my_move(im.Image('misc/ui/proceed.png'))
  File "game/script.rpy", line 61, in python
    
TypeError: object of type 'ATLTransform' has no len()
I'm guessing that this is because Position objects can wrap image objects, but you can't do the same thing with anim.Move objects.

So, is there some way to use Ren'Py animations for the CTC image?

So far, it kind of looks like I need to make a Filmstrip or Animation object, but that's kind of annoying - having to edit images into a "bouncing" animation for the CTC, when (in theory) I should be able to use program logic for that. Plus I'm a programmer, and don't really have art/animation skills :-(

(I guess I could also problematically generate the separate PNG images for the bounce animation, and then load those into the Filmstrip, but that seems a bit extreme. I want to check if there's a simpler way to do this)
Last edited by wizzardx on Sat Sep 24, 2011 7:16 am, edited 1 time in total.

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: How do you make a bouncing "progress" indicator?

#2 Post by Aleema »

Haha, wow that's a complex way to make an animation. Your "obvious" way wasn't at all obvious to me. Have you tried just making an ATL ctc icon?

Code: Select all

image bouncy_icon:
    "misc/ui/proceed.png"
    xalign 0.95 yalign 0.96
    linear 1.0 yalign 0.95
    linear 1.0 yalign 0.96
    repeat
    
define std = Character(None,
    ctc="bouncy_icon", ctc_position='fixed',
    who_outlines=[(1, "#000080")])
Also lol @ character named STD.

wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

Re: How do you make a bouncing "progress" indicator?

#3 Post by wizzardx »

STD is short for "standard" in this case, since it's a type of template I use for all the characters, to give them the same CTC, name outlines, etc :roll:

I did try a bunch of simpler things first including ATL. By obvious, I kind of meant the obvious non-ATL way of doing it, since ATL doesn't seem to play nicely with a lot of non-ATL stuff.

When I use that code, I get this error:

Code: Select all

Full traceback:
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/execution.py", line 261, in run
    node.execute()                                                                                                                                            
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/ast.py", line 1456, in execute                                                                               
    value = renpy.python.py_eval_bytecode(self.code.bytecode)                                                                                                 
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/python.py", line 998, in py_eval_bytecode                                                                    
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 58, in <module>
    ctc=bouncy_icon, ctc_position='fixed',
NameError: name 'bouncy_icon' is not defined

While executing init code:
  File "game/script.rpy", line 57, in script
    define std = Character(None,
  File "game/script.rpy", line 58, in python
        ctc=bouncy_icon, ctc_position='fixed',
NameError: name 'bouncy_icon' is not defined
The problem is, that bouncy_icon is defined.

I also tried putting it in an "init:" sub-block, same problem.

It seems like ATL definitions are a bit tricky, and can't always be used together with defines or Python code. It's a bit like Ren'Py has very special handling for ATL, and images like that can only really be used in specific ways, rather than in a general purpose way like regular images.

For instance, it doesn't seem possible to make an ATL image inside a "define" statement, or inside a python block, otherwise I'd do that in this case.

Could you try making an actual project on your side to test that out (using an ATL image for a CTC image), and see if it works for you?

It's possible that I'm missing something here.

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: How do you make a bouncing "progress" indicator?

#4 Post by Anima »

You didn't use quotation marks in the character definition for the ctc image name according to the traceback.
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: How do you make a bouncing "progress" indicator?

#5 Post by Aleema »

^ Damn, was just going to post and say that.

Also, I think you're overthinking stuff a bit. :P ATL is specifically designed for Ren'Py, so it wasn't designed to work with Python necessarily, and it was created long after Ren'Py had been in development. It's a relatively new feature that most everyone is still learning, but it makes animations waaaay more easier than they previously were. But as it stands, ATL requires certain syntax (image or transform name, colon, indent the instructions), which would break many things since you can't just have a breakline in things like Character calls. You have to send the ATL image name to it instead, like I did.

And I've made several CTCs from ATL code, and Animation() and im.Filmstrip(), so I know it works.

wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

Re: How do you make a bouncing "progress" indicator?

#6 Post by wizzardx »

I think you may be misreading that traceback :|

Here's a complete script.rpy, where I first use a regular character (f) that works, and then after that, a character (e) that attempts to use a bouncing CTC icon:

Code: Select all

# This works: Define a character without a CTC image:
define f = Character('Frank', color="#c8ffc8")

# Now we attempt to make another character, with a bouncy CTC icon:

# Declare the bouncy icon, using ATL:
image bouncy_icon:
    "misc/ui/proceed.png"
    xalign 0.95 yalign 0.96
    linear 1.0 yalign 0.95
    linear 1.0 yalign 0.96
    repeat

# Attempt to create the character:
define e = Character('Eileen', color="#c8ffc8", ctc=bouncy_icon, ctc_position='fixed')
    
# The game starts here.
label start:

    e "You've created a new Ren'Py game."

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

    return
For that, I get a similar traceback to before:

Code: Select all

Full traceback:
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/execution.py", line 261, in run
    node.execute()
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/ast.py", line 1456, in execute
    value = renpy.python.py_eval_bytecode(self.code.bytecode)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/python.py", line 998, in py_eval_bytecode
    return eval(bytecode, globals, locals)
  File "game/script.rpy", line 17, in <module>
    define e = Character('Eileen', color="#c8ffc8", ctc=bouncy_icon, ctc_position='fixed')
NameError: name 'bouncy_icon' is not defined

While executing init code:
  File "game/script.rpy", line 17, in script
    define e = Character('Eileen', color="#c8ffc8", ctc=bouncy_icon, ctc_position='fixed')
  File "game/script.rpy", line 17, in python
    define e = Character('Eileen', color="#c8ffc8", ctc=bouncy_icon, ctc_position='fixed')
NameError: name 'bouncy_icon' is not defined
Any thoughts on this?

Like I mentioned before, I think that while it's valid to declare ATL images that way, and use them with "show" statements later on, there seems to be some limits to combining them with regular code, like you could with regular non-ATL images.

edit: I also tried putting quotes around the bouncy_icon name, like this:

Code: Select all

define e = Character('Eileen', color="#c8ffc8", ctc="bouncy_icon", ctc_position='fixed')
And actually that gets a bit further. But it still crashes during the say line, with this error:

Code: Select all

Full traceback:
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/execution.py", line 261, in run
    node.execute()
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/ast.py", line 396, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/exports.py", line 684, in say
    who(what, interact=interact)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/character.py", line 765, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/character.py", line 661, in do_display
    **display_args)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/character.py", line 468, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/ui.py", line 236, in interact
    rv = renpy.game.interface.interact(**kwargs)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/core.py", line 1667, in interact
    scene_lists.replace_transient()
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/core.py", line 555, in replace_transient
    self.remove(layer, tag)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/core.py", line 825, in remove
    self.hide_or_replace(layer, remove_index, "hide")
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/core.py", line 753, in hide_or_replace
    d = oldsle.displayable._hide(now - st, now - at, prefix)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/screen.py", line 200, in _hide
    c = d._hide(st, at, kind)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/motion.py", line 636, in _hide
    new_child = d.child._hide(st, at, kind)
AttributeError: 'NoneType' object has no attribute '_hide'

While running game code:
  File "game/script.rpy", line 20, in script
        e "You've created a new Ren'Py game."
AttributeError: 'NoneType' object has no attribute '_hide

Anima
Veteran
Posts: 448
Joined: Wed Nov 18, 2009 11:17 am
Completed: Loren
Projects: PS2
Location: Germany
Contact:

Re: How do you make a bouncing "progress" indicator?

#7 Post by Anima »

Your code:

Code: Select all

define e = Character('Eileen', color="#c8ffc8", ctc=bouncy_icon, ctc_position='fixed')
Aleemas Code:

Code: Select all

define e = Character('Eileen', color="#c8ffc8", ctc="bouncy_icon", ctc_position='fixed')
Avatar created with this deviation by Crysa
Currently working on:
  • Winterwolves "Planet Stronghold 2" - RPG Framework: Phase III

wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

Re: How do you make a bouncing "progress" indicator?

#8 Post by wizzardx »

Ah, thanks that works for me now :oops:

I checked my earlier error (in the edit where I ninja'd you):

Code: Select all

While running game code:
  File "game/script.rpy", line 20, in script
        e "You've created a new Ren'Py game."
AttributeError: 'NoneType' object has no attribute '_hide
That was actually caused by my test project not having a copy of "misc/ui/proceed.png" in it.

I was expecting to have a more informative error message.

Anyhow, thanks for the help!

And I guess I understand how ATL images work a bit better now. Rather than making regular Python objects, it seems to (non-intuitively) add new "strings" to the environment.

From what I've seen so far, those quoted strings for images are only ever used for filenames, rather than identifiers.

Are there some docs or examples which show ATL images being used in this way, or which explain it?

edit:

Oops, another problem: While I now do get that bouncy CTC (yay), I'm still getting that crash immediately after clicking the first line in the script.

That suggests that my ATL image is somehow incomplete or declared incorrectly.

This is almost working for me. Here's my code at the moment:

Code: Select all

# This works: Define a character without a CTC image:
define f = Character('Frank', color="#c8ffc8")

# Now we attempt to make another character, with a bouncy CTC icon:

# Declare the bouncy icon, using ATL:
image bouncy_icon:
    "misc/ui/proceed.png"
    xalign 0.95 yalign 0.96
    linear 1.0 yalign 0.95
    linear 1.0 yalign 0.96
    repeat

# Attempt to create the character:
define e = Character('Eileen', color="#c8ffc8", ctc="bouncy_icon", ctc_position='fixed')
    
# The game starts here.
label start:

    e "You've created a new Ren'Py game."

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

    return
I'm getting that crash when I click to proceed on the "You've created a new Ren'Py game.". The bouncy CTC icon is showing up until that point.

Here is the traceback again:

Code: Select all

Full traceback:
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/execution.py", line 261, in run
    node.execute()
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/ast.py", line 396, in execute
    renpy.exports.say(who, what, interact=self.interact)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/exports.py", line 684, in say
    who(what, interact=interact)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/character.py", line 765, in __call__
    self.do_display(who, what, cb_args=self.cb_args, **display_args)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/character.py", line 661, in do_display
    **display_args)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/character.py", line 468, in display_say
    rv = renpy.ui.interact(mouse='say', type=type, roll_forward=roll_forward)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/ui.py", line 236, in interact
    rv = renpy.game.interface.interact(**kwargs)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/core.py", line 1667, in interact
    scene_lists.replace_transient()
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/core.py", line 555, in replace_transient
    self.remove(layer, tag)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/core.py", line 825, in remove
    self.hide_or_replace(layer, remove_index, "hide")
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/core.py", line 753, in hide_or_replace
    d = oldsle.displayable._hide(now - st, now - at, prefix)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/screen.py", line 200, in _hide
    c = d._hide(st, at, kind)
  File "/home/david/dev/renpy/renpy-6.12.2/renpy/display/motion.py", line 636, in _hide
    new_child = d.child._hide(st, at, kind)
AttributeError: 'NoneType' object has no attribute '_hide'

While running game code:
  File "game/script.rpy", line 20, in script
        e "You've created a new Ren'Py game."
AttributeError: 'NoneType' object has no attribute '_hide'
Any further suggestions?

wizzardx
Regular
Posts: 72
Joined: Thu Mar 19, 2009 2:35 am
Projects: An Ordinary Life, and various short Ar tonelico VNs
Location: At Frelia's side
Contact:

Re: How do you make a bouncing "progress" indicator?

#9 Post by wizzardx »

I updated to the newest version, 6.13.0, and it works for me now 8) . Thanks for the help.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], fufuffiero