Page 1 of 1

[solved] How to make a separate button to this function (textbutton/imagebutton)?

Posted: Tue Jan 08, 2019 7:26 pm
by Nanahs
I'm using this code to let the player choose their bedroom background:

Code: Select all

default bdr = 'a'
image bedroom = 'bedroom[bdr].jpg'

screen chosebedroom():
    text 'Choose your bedroom.' align(.7, .3)
    hbox at truecenter:
        spacing 7
        imagebutton idle im.FactorScale('bedrooma.jpg', .2) action SetVariable('bdr', 'a'), Return()
        imagebutton idle im.FactorScale('bedroomb.jpg', .2) action SetVariable('bdr', 'b'), Return()
        imagebutton idle im.FactorScale('bedroomc.jpg', .2) action SetVariable('bdr', 'c'), Return()
        imagebutton idle im.FactorScale('bedroomd.jpg', .2) action SetVariable('bdr', 'd'), Return()  
It looks something like this:

Image

When the player clicks on the image, the game sets it as "image bedroom."

But I wanted to do something like this:

Image

I know that would be more "trouble", since I'd have to create more screens. But I really want to have this "Background" button under each image.

So basically I'd have to create a screen (for each image) with a textbutton "Background", right?
I tried doing this but I failed at "converting" the information from the imagebutton to the textbutton.
It's also necessary to add a position to the textbutton to stay at the right place.

What's the order of the text "Background", position, action, etc? I tried many different ways and got the "not a keyword argument or valid child for the textbutton statement." error.

Thanks.

Re: How to make a separate button to this function (textbutton/imagebutton)?

Posted: Wed Jan 09, 2019 6:13 pm
by Viarch
sorry for my english, you just want to add some text to imagebuttons ? if yes, you can add text directly to images.

Re: How to make a separate button to this function (textbutton/imagebutton)?

Posted: Wed Jan 09, 2019 8:31 pm
by Nanahs
Viarch wrote: Wed Jan 09, 2019 6:13 pm sorry for my english, you just want to add some text to imagebuttons ? if yes, you can add text directly to images.
Hello! Actually I'm trying to discover how to adjust the action from that imagebutton to a textbutton.

I know this one:

Code: Select all

textbutton _("choice") action SetField(persistent, "variable", "value")
I just don't know how to use it with the images yet.

But thanks for trying to help :)

ps: English is not my first language too :lol:

Re: How to make a separate button to this function (textbutton/imagebutton)?

Posted: Wed Jan 09, 2019 9:18 pm
by Imperf3kt
The action should be identical. A textbutton is a button, and am imagebutton is a button. Any action a textbutton can use, an imagebutton can too, since they're both buttons.

Alternatively, you could use a button and supply both an image and text (if desired) and use it in the same way.

Re: How to make a separate button to this function (textbutton/imagebutton)?

Posted: Thu Jan 10, 2019 6:00 am
by Remix

Code: Select all

textbutton "The Text Bit":
    # maybe some styles or style name to adjust positions of each part

    idle_background "background_image.png"
    # maybe with hover_ etc etc # this goes below the text

    idle_foreground "bedrooma.png"
    # maybe with hover_ as well etc # this goes above

    focus_mask "some_image_to_define_mask_area.png"
    # no hover_ needed # this isn't shown
You can use Frame() or Transform() for bg/fg/focus too

Re: How to make a separate button to this function (textbutton/imagebutton)?

Posted: Thu Jan 10, 2019 7:52 am
by Nanahs
Imperf3kt wrote: Wed Jan 09, 2019 9:18 pm The action should be identical. A textbutton is a button, and am imagebutton is a button. Any action a textbutton can use, an imagebutton can too, since they're both buttons.

Alternatively, you could use a button and supply both an image and text (if desired) and use it in the same way.
Oh, ok. I just got confused because in this case:

Code: Select all

        imagebutton idle im.FactorScale('bedrooma.jpg', .2) action SetVariable('bdr', 'a'), Return()
The button is the image (that's why it's called imagebutton, right? :lol: ).
I don't know how to make a texbutton that would make "bedrooma.jpg" "SetVariable". Do you know what I mean? My explanation is confusing :oops: :lol:

If I do:

Code: Select all

        textbutton idle im.FactorScale('bedrooma.jpg', .2) action SetVariable('bdr', 'a'), Return()
It's not simply like that. Or is it? :?: Where would I write "Background"? I'm confused about how do I combine the text "Background" with the action, and show it instead of showing the image.
The image I'd show normally as a "show bedrooma", so that the person you'd now that when clicking on the "Background" under that image, that would be the one they' are choosing.

OMG :?: :?: :lol:

Re: How to make a separate button to this function (textbutton/imagebutton)?

Posted: Thu Jan 10, 2019 8:04 am
by Nanahs
Remix wrote: Thu Jan 10, 2019 6:00 am

Code: Select all

textbutton "The Text Bit":
    # maybe some styles or style name to adjust positions of each part

    idle_background "background_image.png"
    # maybe with hover_ etc etc # this goes below the text

    idle_foreground "bedrooma.png"
    # maybe with hover_ as well etc # this goes above

    focus_mask "some_image_to_define_mask_area.png"
    # no hover_ needed # this isn't shown
You can use Frame() or Transform() for bg/fg/focus too
Thank you so much!
I just don't know, what "focus_mask" is for? And "idle_background "background_image.png" is any image that I just set as a "standard" background?
Sorry, those terms confuse me a little. I always have to search the meaning of "idle" because I forget :oops: :lol: (English is not my language).