[SOLVED] Imagebutton hovered changes Cursor

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
newpy
Newbie
Posts: 9
Joined: Tue Apr 17, 2012 1:49 pm
Contact:

[SOLVED] Imagebutton hovered changes Cursor

#1 Post by newpy » Sat Jan 26, 2013 11:34 am

Hi Everybody :) ,

I have made a "Button" that starts an Action and also change the Mousecursor on hovering.
This could be nice for a Magnifier,Arrow or so.

It works (the grey image should be much bigger).

Problem:
Hovering the white Button the first time result in ugly delay.

Could i fix that? Image Cache is empty. Sorry i'm non programmer and need to change cursor on hovering. :|

(The attachment shows a white imagebutton over a black one. White change the cursor to "arrow" and black button back to "default".)

Code: Select all


init:
    $ mouse_is =0
    image bg Home_R1 = "images/Home_R1/Room_R1_0.png"
    image xtop = "images/items/top.png"
    image xbottom = "images/items/bottom.png"
    image DESK = "images/Home_R1/Dummy_PC.png"

# The game starts here.
label start:
    
label begin:

    scene bg Home_R1 at truecenter
    show xtop at top
    show xbottom at center
    
	 # Image ready for ATL Action as long as white Button is hovered.
    if mouse_is ==1:
        show DESK behind character_main_anim_PC:
            xalign 1.0 yalign 0.607
    elif mouse_is ==0:
        hide DESK       

    python:
        
       # ICON
       if mouse_is == 1:
           ui.vbox(xalign=1.0, yalign=0.55) # Only show if the White Button is hoverd (should be transparent PNG in Game)
           ui.imagebutton("images/Home_R1/Dummy_PC_R.png", "images/Home_R1/Dummy_PC_R.png", clicked=ui.returns(None), hovered=ui.returns(32))
           ui.close()
       ui.vbox(xalign=1.0, yalign=0.55) # (should be transparent PNG in Game)
       ui.imagebutton("images/Home_R1/Dummy_PC.png", "images/Home_R1/Dummy_PC.png", clicked=ui.returns(3), hovered=ui.returns(31))
       ui.close()
    $ result = ui.interact()
               #
    if result == 3:
        jump Desk
    elif result == 31:
        $ config.mouse = { 'default' : [ ('images/arrow.png', 0, 0)] }
        $ mouse_is =1
        jump begin
    elif result == 32:
        $ config.mouse = { 'default' : [ ('mouse.png', 0, 0)] }
        $ mouse_is =0
        jump begin
Attachments
imagebutton.png
Last edited by newpy on Mon Jan 28, 2013 2:28 pm, edited 1 time in total.

User avatar
Alex
Lemma-Class Veteran
Posts: 2522
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: Imagebutton hovered changes Cursor [HELP Needed]

#2 Post by Alex » Sun Jan 27, 2013 7:16 am

Buttons have a mouse property that can be set to make mouse pointer change while this button is hovered - http://www.renpy.org/doc/html/style.htm ... properties (all this pointers must be defined in init block using config.mouse variable).
Also, changing of config or style variables midgame can't be stored - http://www.renpy.org/doc/html/save_load_rollback.html#

newpy
Newbie
Posts: 9
Joined: Tue Apr 17, 2012 1:49 pm
Contact:

Re: Imagebutton hovered changes Cursor [SOLVED]

#3 Post by newpy » Sun Jan 27, 2013 12:19 pm

Now i can use an imagebutton that changes when hovered and also the cursor changes.
Thank you for your help.

Code: Select all


init:           
    $ config.mouse = { "default": (('images/cursor/cursor_DEFAULT.png', 0, 0), ('images/cursor/cursor_DEFAULT.png', 0, 0)),
                                     "aktion": (('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_AKTIV.png', 0, 0),
                                         ('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_AKTIV.png', 0, 0),
                                         ('images/cursor/cursor_AKTIV.png', 0, 0), ('images/cursor/cursor_DEFAULT.png', 0, 0), ('images/cursor/cursor_DEFAULT.png', 0, 0), ('images/cursor/cursor_DEFAULT.png', 0, 0), ('images/cursor/cursor_DEFAULT.png', 0, 0),
                                         ('images/cursor/cursor_DEFAULT.png', 0, 0), ('images/cursor/cursor_DEFAULT.png', 0, 0), ('images/cursor/cursor_DEFAULT.png', 0, 0),('images/cursor/cursor_DEFAULT.png', 0, 0),('images/cursor/cursor_DEFAULT.png', 0, 0),
                                         ('images/cursor/cursor_DEFAULT.png', 0, 0),('images/cursor/cursor_DEFAULT.png', 0, 0)) }
                      
    
    image bg Home_R1 = "images/Home_R1/Room_R1_0.png"
    image xtop = "images/items/top.png"
    image xbottom = "images/items/bottom.png"

# The game starts here.
label start:
    
label begin:
 
    scene bg Home_R1 at truecenter
    show xtop at top
    show xbottom at center
        
    python:
       ui.vbox(xalign=1.0, yalign=0.607)
       ui.imagebutton("images/Home_R1/Dummy_PC_Leer.png", "images/Home_R1/Dummy_PC.png", clicked=ui.returns(3), mouse=("aktion"))
       ui.close()
    $ result = ui.interact()
        #
    if result == 3:
        jump Desk
    jump begin

    return






Post Reply

Who is online

Users browsing this forum: Google [Bot]