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.
-
Katy133
- Miko-Class Veteran
- Posts: 704
- Joined: Sat Nov 16, 2013 1:21 pm
- Completed: Eight Sweets, The Heart of Tales, [redacted] Life, Must Love Jaws, A Tune at the End of the World, Three Guys That Paint, The Journey of Ignorance, Portal 2.5.
- Projects: The Butler Detective
- Tumblr: katy-133
- Deviantart: Katy133
- Soundcloud: Katy133
- itch: katy133
- Location: Canada
-
Contact:
#1
Post
by Katy133 » Wed Mar 02, 2016 12:02 am
I want to switch the mouse cursor's image mid-game.
This is what I have so far:
Code: Select all
config.mouse = { }
config.mouse["default"] = [
("images/mouse_icon.png", 0.0, 0.0),
]
I want to switch between "mouse_icon.png" and "mouse_icon_2.png" using a persistent switch:
I'd like the following to happen in-game:
Code: Select all
e "Dialogue"
# Mouse changes here
e "More dialogue"
I'm not sure what code to use and where (I'm pretty new to programming).
Last edited by
Katy133 on Wed Mar 02, 2016 6:26 pm, edited 1 time in total.
-
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:
#2
Post
by PyTom » Wed Mar 02, 2016 1:13 am
Ren'Py's mous handling isn't flexible enough to pull this off.
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
-
xela
- Lemma-Class Veteran
- Posts: 2481
- Joined: Sun Sep 18, 2011 10:13 am
-
Contact:
#3
Post
by xela » Wed Mar 02, 2016 6:42 am
Something along these lines may work:
Code: Select all
init 1 python:
def change_cursor(type="default"):
persistent.mouse = type
if type == "default":
setattr(config, "mouse", None)
elif type == "1":
setattr(config, "mouse", {"default": [("images/1.png", 0, 0)]})
elif type == "2":
setattr(config, "mouse", {"default": [("images/2.png", 0, 0)]})
if not hasattr(persistent, "mouse"):
change_cursor()
else:
change_cursor(persistent.mouse)
# The game starts here.
label start:
$ change_cursor()
"Normal Cursor"
$ change_cursor("1")
"Cursor 1"
$ change_cursor("2")
"Cursor 2"
return
There is also a more complicated option where you remove the normal cursor and use a DD/UDD instead, in such a case, you can even animate cursors.
Like what we're doing? Support us at:

-
Katy133
- Miko-Class Veteran
- Posts: 704
- Joined: Sat Nov 16, 2013 1:21 pm
- Completed: Eight Sweets, The Heart of Tales, [redacted] Life, Must Love Jaws, A Tune at the End of the World, Three Guys That Paint, The Journey of Ignorance, Portal 2.5.
- Projects: The Butler Detective
- Tumblr: katy-133
- Deviantart: Katy133
- Soundcloud: Katy133
- itch: katy133
- Location: Canada
-
Contact:
#4
Post
by Katy133 » Wed Mar 02, 2016 6:22 pm
xela wrote:Something along these lines may work:
Code: Select all
init 1 python:
def change_cursor(type="default"):
persistent.mouse = type
if type == "default":
setattr(config, "mouse", None)
elif type == "1":
setattr(config, "mouse", {"default": [("images/1.png", 0, 0)]})
elif type == "2":
setattr(config, "mouse", {"default": [("images/2.png", 0, 0)]})
if not hasattr(persistent, "mouse"):
change_cursor()
else:
change_cursor(persistent.mouse)
# The game starts here.
label start:
$ change_cursor()
"Normal Cursor"
$ change_cursor("1")
"Cursor 1"
$ change_cursor("2")
"Cursor 2"
return
There is also a more complicated option where you remove the normal cursor and use a DD/UDD instead, in such a case, you can even animate cursors.
That works! Thank you!
