Setting Live2d Animation by Image Button action?

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
MaxLib
Newbie
Posts: 6
Joined: Sat Feb 13, 2021 3:25 pm
Completed: none yet.
Projects: Under Development
Deviantart: MaximumLiberty
Contact:

Setting Live2d Animation by Image Button action?

#1 Post by MaxLib »

Hello! I'd like to ask how to set the Live2d animation "m01" to an image button's action? I would like to change motion file m01, m02 with buttons.

MaxLib
Newbie
Posts: 6
Joined: Sat Feb 13, 2021 3:25 pm
Completed: none yet.
Projects: Under Development
Deviantart: MaximumLiberty
Contact:

Re: Setting Live2d Animation by Image Button action?

#2 Post by MaxLib »

I came up with a simple solution to get full interactive controll over live2d model's animations.
First I used the choice menu but it is designed for other purposes.Next I chose to use imageButton so it could be customized and
transformed easely.I'm not a programmer, I have limited knowledge of renpy language but this is working well at least for me.
I decided to share it here. :)

To get perfect animation in renpy you must set seamless=True and loop=True otherwise it is not going to give perfectly looped animation.

Code: Select all

image NpcLive2d = Live2D("live2D_animation/NpcLive2d",  base=0.9, top=0.6, height=0.4, seamless=True,  loop=True, fade=True )

Code: Select all

screen Buttons():
        
    imagebutton:
        idle "images/BUTTON_Stop.png"
        hover "images/BUTTON_Stop_hov.png"
        action Jump("AnimIdle")
    
    imagebutton:
        idle "images/BUTTON_Play.png"
        hover "images/BUTTON_Play_hov.png"
        action Jump("AnimPlay")                
                
label AnimStartHere: ## The game jumps here first from anywhere.
    
    show screen Buttons
    jump AnimIdle
    $ renpy.pause(hard=True)
    
label AnimIdle: ## This is the basic movement of the model, it is running continuously
    
    show NpcLive2d m01 
    $ renpy.pause(hard=True)

label AnimPlay: ## This is one of the many animations what can be triggered realtime. 

    show NpcLive2d m02 
    $ renpy.pause(hard=True)  

Post Reply

Who is online

Users browsing this forum: Dark79, Google [Bot], Majestic-12 [Bot]