using Frame() to match button - or CDD help

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
nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

using Frame() to match button - or CDD help

#1 Post by nananame » Tue Sep 29, 2020 4:36 am

I apologize for the strange title but have no better idea what to put. Basically, I have an image button which is animated.

Code: Select all

image animatedbutton:
    "images/anim1.png"
    0.5
    "images/anim2.png"
    repeat

imagebutton:
   idle "animatedbutton"
I'd like the button to have an outline when hovered, but without using a separate image for that (since there will be a lot of these).
So I figured the best way (let me know if there's a better way) is to use an image as a background which is shown on hover. The image should, of course, be resized to fit the original image. So now I have this:

Code: Select all

imagebutton:
    idle "animatedbutton"
    hover_background Frame("images/testframe.png")
##I use hover_background instead of hover because hover would load the frame instead of the animation

It works but here's the problem - my button isn't a regular rectangle. It's like a person. So when the background Frame stretches to fit, if ends up looking rectangular.

Images:
idle button:
Image
hovered with the frame result:
Image
desired result:
Image

So is there a better way to do this or can I make this work somehow? I tried making the testframe.png have just a border but it again ends up as a rectangular border; I tried just putting a bit of color in the middle of the testframe.png but it doesn't extend enough then and, again, it resizes in a square way...
I thought about using a UDD instead of an image but two problems with that - not sure how it would work with the image constantly changing size (as it is an animated image) and not really sure how to code that :D

So, help appreciated.
Last edited by nananame on Tue Sep 29, 2020 6:10 am, edited 1 time in total.

User avatar
hell_oh_world
Miko-Class Veteran
Posts: 777
Joined: Fri Jul 12, 2019 5:21 am
Projects: The Button Man
Organization: NILA
Github: hell-oh-world
Location: Philippines
Contact:

Re: using Frame() to match button

#2 Post by hell_oh_world » Tue Sep 29, 2020 6:04 am

That's not how Frame works, your best bet I think is to have a separate image that acts as the border. With regards to your assets being to many to do that, in adobe photoshop, you can always use the action recorder to make a one time record of how you do border your images and bind them to a hotkey, then use scripts maybe to export all at once.

nananame
Regular
Posts: 72
Joined: Fri Oct 13, 2017 1:40 pm
Contact:

Re: using Frame() to match button

#3 Post by nananame » Tue Sep 29, 2020 6:10 am

hell_oh_world wrote:
Tue Sep 29, 2020 6:04 am
That's not how Frame works, your best bet I think is to have a separate image that acts as the border. With regards to your assets being to many to do that, in adobe photoshop, you can always use the action recorder to make a one time record of how you do border your images and bind them to a hotkey, then use scripts maybe to export all at once.
It's not just making them in photoshop that's the problem but having so many of them in the game. And yes, I have a feeling Frame() won't be able to arrange itself nicely. So perhaps help with writing a UDD (or CDD, creator defined displayable) would be good too :)

Post Reply

Who is online

Users browsing this forum: Google [Bot], TioNick