Creating a Skip Movie Button

A place for Ren'Py tutorials and reusable Ren'Py code.
Forum rules
Do not post questions here!

This forum is for example code you want to show other people. Ren'Py questions should be asked in the Ren'Py Questions and Announcements forum.
Post Reply
Message
Author
User avatar
williamd1k0
Newbie
Posts: 19
Joined: Sat Feb 07, 2015 3:08 am
Completed: Catalendas
Projects: Ren'Py for Atom
Organization: Novastrike Media
Github: williamd1k0
itch: williamd1k0
Contact:

Creating a Skip Movie Button

#1 Post by williamd1k0 » Thu Mar 05, 2015 4:56 pm

Hi! :)
After several frustrating attempts to create a way to skip a video with a button, I could create a solution, which so far is working perfectly. I will here share the codes for those who want to make use of this function and also to improve it. Recalling that was used to "Movie()" class, this because the "renpy.movie_cutscene()" did not support this method.
Remember to delete/replace what is written between hashtag "#".
I hope you can understand my English translated by Google!

In screens.rpy:

Code: Select all

screen skipbutton:

    modal True  #prevents mouse interaction and several other keys#

    key "K_h" action Hide("nonexistent_screen")   #prevents the screen to be hidden#
    key "K_f" action Hide("nonexistent_screen")   #prevents it from being toggled fullscreen#
    key "mouseup_2" action Hide("nonexistent_screen")   #prevents the screen to be hidden#

    add ui.timer(movieTime, ui.jumps("skipmovie"))   #change "movieTime" by video time in seconds or so#

    imagebutton idle "buttoniIdle.png" hover "buttonHover.png" #button position parameters# focus_mask True action Jump("skipmovie")
    #rename the image button files#
In script.rpy (can be in another file using "init"):

Code: Select all

image movie = Movie(size=(1024, 768))   #change the values pending resolution of the video#
In some game script file, create a label to call when play the video:

Code: Select all

label videotoplay:   #change "videotoplay" to the name you want#

    $ movieTime = #movie time in seconds (float)#
    show movie
    play movie #moviename(file)#
    show screen skipbutton   #to activate the skip button screen#

    $ renpy.pause(hard=True)  #prevent ultimately the game straight away without finishing the video#
return

label skipmovie:

    hide screen skipbutton   #disables the skip button screen#
    stop movie
    hide movie
return
During the game, call the video label:

Code: Select all

call videotoplay
Attachments
screenshot0001.png
Last edited by williamd1k0 on Fri Mar 06, 2015 2:17 pm, edited 1 time in total.

User avatar
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:

Re: Creating a Skip Movie Button

#2 Post by PyTom » Fri Mar 06, 2015 2:05 am

Note that this only works on PC - the mobile platforms only support fullscreen video, not Movie().
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

User avatar
williamd1k0
Newbie
Posts: 19
Joined: Sat Feb 07, 2015 3:08 am
Completed: Catalendas
Projects: Ren'Py for Atom
Organization: Novastrike Media
Github: williamd1k0
itch: williamd1k0
Contact:

Re: Creating a Skip Movie Button

#3 Post by williamd1k0 » Fri Mar 06, 2015 1:41 pm

Wow! I never got to test a video on mobile, I did not know that did not work the Movie().
Thank you for warning! :wink:

Post Reply

Who is online

Users browsing this forum: No registered users