Wanna make your own app?
In order to do that, you need two things:
A phone screen
A
phone.application.Applicationobject (not necessary but if you want your app to appear on thephonescreen then yes you need this)
The _phone screen
To create a phone screen, simply use the _phone screen, intended as base for all phone screen.
screen my_phone_screen():
use _phone():
# your screen code goes there
The _phone screen has 5 parameters:
xposThe xpos of the phone.yposThe ypos of the phone.xanchorThe xanchor of the phone.yanchorThe yanchor of the phone.horizontalIf true, the phone is displayed horizontally. If false, it is displayed vertically.
Once you’ve coded your screen, simply call it with phone.call_screen or the PhoneMenu action and there you go!
Applications
If you want your app to appear on the phone screen, you need to create a phone.application.Application object and add it to your *character*s.
The following functions and classes are defined in the phone.application namespace.
class Application(object)
def __init__(self, name, icon, action)
nameA string. The name of the app.iconAphone.application.Iconorphone.application.GradientBackgroundobject.actionAn action to run when clicking on the app (most of the time it’s aPhoneMenuaction, but any valid action works).
def Icon(d, size=None, background=None)Retuns a displayable used as icon for applications.
dis a displayable to add on to the icon.sizeis the size that displayable takes.background, if notNone, is aphone.application.IconBackgroundorphone.application.GradientBackgroundobject displayed behindd.def GradientBackground(start_color, end_color, theta=0)Retuns a
phone.application.IconBackgroundobject with aGradientas displayable.def IconBackground(d, **kwargs)Returns
dwith rounded corners of sizegui.phone_application_icon_size.
Example
init python:
my_app = phone.application.Application(
"my application",
phone.application.GradientBackground("#5bf676", "#04be25"),
PhoneMenu("my_phone_screen")
)
Now that you’ve done this, it’s time to add the app to the *character*s you’ve defined, using those two functions.
def add_application(app, page=0, key=None)Adds the application
appto the known applications for*character*key. ReturnsTrueif it succesfully added the app,Falseif it failed, orNoneif Ren’Py is still in init phase.def add_app_to_all_characters(app, page=0)Same as above but for every
*character*known at execution time.
To add the app you’ve created, simply
phone.application.add_app_to_all_characters(my_app)
and ta-da, your app should appear on the phone screen.
Functions
def move_application(start, end, key=None)start/endare 3-tuples containing a page, a column and a row. They represent the start/end point. This function swaps the application of coordinatesstartwith the one of coordinatesend.