How to make text stationary?

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
Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

How to make text stationary?

#1 Post by Nero »

I got this annoying problem where numbers that are placed on my HP bar just wont stay pinned on the bar. For example at the start of game everything looks perfect like this
Image

And after those numbers get to 3 or lower decimals this happens messing up the center positioning.
Image

Here is my code:

Code: Select all

screen battle_info:                 
    hbox:
        spacing 125
        xalign 0.500 yalign 0.271
        if enemy_members_list != []:
            for i, each_enemy_member in enumerate(enemy_members_list):        
                hbox:
                    add DUMMY_STATS.PLAYER_TEST_BG
                    text "{color=#000000}[each_enemy_member.TOTAL_CURRENT_HP] / [each_enemy_member.TOTAL_MAX_HP]{/color}" bold True  size 14    
                    
                    
    hbox:
        spacing 165
        xalign 0.500 yalign 0.296
        if enemy_members_list != []:
            for i, each_enemy_member in enumerate(enemy_members_list):        
                hbox:
                    add DUMMY_STATS.PLAYER_TEST_BG
                    text "{color=#000000}[each_enemy_member.MAX_MANA] / [each_enemy_member.CURRENT_MANA]{/color}" bold True size 14
Note that I do not want to use frames because then i cant get numbers to be inside the health bars it looks ugly then.. My idea is maybe there is a way to get invisible frame that acts as a normal frame but is not shown on the screen? Is this even possible to do?

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: How to make text stationary?

#2 Post by SundownKid »

You need to add an additional xalign for the text itself.

philat
Eileen-Class Veteran
Posts: 1909
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: How to make text stationary?

#3 Post by philat »

Based on your setup, looks like the width of the hbox is changing based on the length of the string (i.e., the box is only as large as the string inside, and 20000/20000 is longer than 0/20000). Try specifying a xminimum.

That said, wouldn't it make more sense to have each character's box (i.e., the health/mana set), be one logical unit rather than all characters' health / all characters' mana? Whatever works for you though, I guess.

Nero
Veteran
Posts: 248
Joined: Tue Aug 09, 2016 2:59 pm
Contact:

Re: How to make text stationary?

#4 Post by Nero »

Yup specifying the xminimum fixed the problem thanks. Hmm yes I wanted to do it this way but when I put everything in one hbox all my object push around each other which messes up my whole screen. Maybe im doing it wrong I did something like this but everything on screen was out of position...

Code: Select all

screen battle_info:                 
    hbox:
        spacing 125
        xalign 0.500 yalign 0.271
        if enemy_members_list != []:
            for i, each_enemy_member in enumerate(enemy_members_list):        
                hbox:
                    add DUMMY_STATS.PLAYER_TEST_BG
                    text "{color=#000000}[each_enemy_member.TOTAL_CURRENT_HP] / [each_enemy_member.TOTAL_MAX_HP]{/color}" bold True  size 14
                    
                    add DUMMY_STATS.PLAYER_TEST_BG
                    text "{color=#000000}[each_enemy_member.MAX_MANA] / [each_enemy_member.CURRENT_MANA]{/color}" bold True size 14

Post Reply

Who is online

Users browsing this forum: Google [Bot]