Image performance with extra transparent area

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
valery_iwanofu
Newbie
Posts: 7
Joined: Tue May 18, 2021 2:56 am
Contact:

Image performance with extra transparent area

#1 Post by valery_iwanofu » Tue May 18, 2021 3:37 am

I'm making an ADV game and I have a couple of questions about images with extra transparent area.
I'm trying to make interactive objects using the screen system and I found the following options to implement this:
  1. imagebutton with focus_mask and screen size image

    Code: Select all

    imagebutton:
        idle 'images/objects/Door.png'
        hover 'images/objects/Door_Hover.png'
        focus_mask True
        action NullAction()
    
  2. imagebutton with cropped image and specified position

    Code: Select all

    imagebutton:
        idle 'images/objects/Door.png'
        hover 'images/objects/Door_Hover.png'
        #focus_mask True
        
        xpos 500
        ypos 600
        
        action NullAction()
    
  3. same as previous but Null used instead of idle image(background image contains idle image)

    Code: Select all

    imagebutton:
        idle Null(width=300, height=600)
        hover 'images/objects/Door_Hover.png'
        
        xpos 500
        ypos 600
        
        action NullAction()
    
First option is simple but slow.
Second and third options have better performance but require manual image positioning.

The question is, how slow is the focus_mask with a 1920x1080 image and is it worth optimizing?

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

Re: Image performance with extra transparent area

#2 Post by Alex » Tue May 18, 2021 3:23 pm

valery_iwanofu wrote:
Tue May 18, 2021 3:37 am
...The question is, how slow is the focus_mask with a 1920x1080 image and is it worth optimizing?
First thing to optimize - declare all images and use aliases instead of direct file paths in buttons

Code: Select all

image door_idle:
    'images/objects/Door.png'

image door_hover:
    'images/objects/Door_Hover.png'


screen screen_name():
    imagebutton:
        idle 'door_idle'
        hover 'door_hover'
        focus_mask True
        action NullAction()
And it's better to positioning small buttons onscreen rather than have fullscreen-sized ones.

Check some links
viewtopic.php?f=8&t=52419&p=498567&hilit=cache#p498567

viewtopic.php?f=51&t=47328&p=479085&hilit=cache#p479085

https://www.renpy.org/doc/html/config.h ... cache_size

Post Reply

Who is online

Users browsing this forum: CharlieFuu69, Google [Bot], Ocelot