showing a motionless imagebutton on an imagemap w/ transform

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
User avatar
Rainvillain
Regular
Posts: 74
Joined: Thu Mar 05, 2015 11:27 am
Contact:

showing a motionless imagebutton on an imagemap w/ transform

#1 Post by Rainvillain » Mon Oct 24, 2016 3:35 pm

Hi there!

I'm trying to figure out how to make a UI/imagebutton element not be affected by the transform that causing the rest of the screen to move.

I have an imagemap where the screen has a minor shake/swaying affect on it (to emulate the effect of a boat out at sea). The player can click on various doors on this shot to access different parts of the ship. There's also a bottle that the player can pick up that I've created as an imagebutton.
I'm using a custom transform to create the illusion of motion. That looks like this:

Code: Select all

init-2:
    transform ship_sway:
        ypos 0 
        linear 0.8 ypos -5
        linear 0.8 ypos 0
And this is what my imagemap looks like:

Code: Select all

screen imagemap1:
    imagemap at ship_sway:
        ground "imagemap1"
        hover "imagemap1 hover"
        hotspot (548, 131, 181, 84) action Jump("room1")
        hotspot (889, 40, 194, 304) action Jump("room2")
        imagebutton auto "bottle_%s.png" action Jump("bottle1") xpos 25 ypos 500 focus_mask True
Because of the ship_sway, everything on screen sways in time (including the imagebutton of the bottle).

But then, what if I also wanted to have a UI icon that was clickable during this imagemap that WASN'T affected by the ship_sway..?
I was thinking of adding this UI element (in this case, a journal icon that you can click on to reach the pause menu) as an imagebutton, but whenever I do this, it also sways with the rest of the imagemap..
Is there any easy way of showing this UI/imagebutton during the imagemap without it inheriting the transform properties of the rest of the imagemap?

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: showing a motionless imagebutton on an imagemap w/ trans

#2 Post by Ocelot » Mon Oct 24, 2016 4:42 pm

You are adding your imagebutton as part of imagemap. Add it as its own element (you probably would need a container to hold both imagemap and button)

Code: Select all

screen imagemap1:
    imagemap at ship_sway:
        ground "imagemap1"
        hover "imagemap1 hover"
        hotspot (548, 131, 181, 84) action Jump("room1")
        hotspot (889, 40, 194, 304) action Jump("room2")
    imagebutton auto "bottle_%s.png" action Jump("bottle1") xpos 25 ypos 500 focus_mask True
< < insert Rick Cook quote here > >

User avatar
Rainvillain
Regular
Posts: 74
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Re: showing a motionless imagebutton on an imagemap w/ trans

#3 Post by Rainvillain » Tue Oct 25, 2016 8:46 am

Ocelot wrote:You are adding your imagebutton as part of imagemap. Add it as its own element (you probably would need a container to hold both imagemap and button)
Oh WOW, I didn't realize you could have separate indentation levels in the same screen... haha, thanks a lot for clearing that up for me! This changes everything, haha..

I tried it and it works perfectly. Thanks again.
Follow up question: if I wanted to have that imagebutton shown throughout the entire game (or at least until I tell it to hide, is there any easy way of putting that into the code? Because right now I'm just showing it after every new jump/label/screen...
Currently working on Cross the Moon
https://patrick-rainville.itch.io/cross-the-moon

User avatar
Ocelot
Eileen-Class Veteran
Posts: 1883
Joined: Tue Aug 23, 2016 10:35 am
Github: MiiNiPaa
Discord: MiiNiPaa#4384
Contact:

Re: showing a motionless imagebutton on an imagemap w/ trans

#4 Post by Ocelot » Tue Oct 25, 2016 8:57 am

Create a new screen with this button and show it using show screen. It will be kept through jumps, calls, etc. until you hide it:

Code: Select all

screen important_button:
    zorder 5 # Ensures that it will be shown above everything
    imagebutton auto "bottle_%s.png" action Jump("bottle1") xpos 25 ypos 500 focus_mask True

# later in script
show screen important_button
< < insert Rick Cook quote here > >

User avatar
Rainvillain
Regular
Posts: 74
Joined: Thu Mar 05, 2015 11:27 am
Contact:

Re: showing a motionless imagebutton on an imagemap w/ trans

#5 Post by Rainvillain » Tue Oct 25, 2016 9:25 am

Ocelot wrote:Create a new screen with this button and show it using show screen. It will be kept through jumps, calls, etc. until you hide it:
Thanks a lot Ocelot. I'll be sure to thank you in my game's credits :)
Currently working on Cross the Moon
https://patrick-rainville.itch.io/cross-the-moon

Post Reply

Who is online

Users browsing this forum: No registered users