How to create an image with both pictures and text

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
drmindflip
Newbie
Posts: 7
Joined: Thu Jun 18, 2020 8:15 pm
Contact:

How to create an image with both pictures and text

#1 Post by drmindflip » Thu Jun 18, 2020 8:18 pm

I'm creating a card game and I want the cards to consist of:
(a) An image of the card, art, etc.
(b) Some text overlayed onto it - because I want this to possibly change in-game

I've got all my card images displaying nicely using Composite...

Code: Select all

image beast hunter = im.Composite (None,
    (0, 0), im.FactorScale("beast hunter.png", 0.8))
...but I just can't manage to get any text in there! Can you add text to a composite? If not, is there a better way of doing this? I'm going mad trying to get this going! Thank you :?

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

Re: How to create an image with both pictures and text

#2 Post by hell_oh_world » Thu Jun 18, 2020 8:59 pm

Another way to do this is by using screen, and use `use` statement to reuse the screen.

Code: Select all

image card1 = "c1.png"

screen card(image_name, description):
  frame:
    xysize (100, 250)
    background image_name
    
    text description align (0.5, 0.75)

screen cards:
  hbox:
    use card("card1", "Card 1")
    use card("c2.png", "Card 2")

label start:
  show screen cards
  "Some dialogue..."

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

Re: How to create an image with both pictures and text

#3 Post by philat » Thu Jun 18, 2020 11:45 pm

You can also add text to a composite image using Text().

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3000
Joined: Mon Dec 14, 2015 5:05 am
Location: Your monitor
Contact:

Re: How to create an image with both pictures and text

#4 Post by Imperf3kt » Fri Jun 19, 2020 2:45 am

Imagebuttons can also take a Text displayable for their various idle and hover foreground states.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Twitter
Imperf3kt Blackjack - a WIP blackjack game for Android made using Ren'Py
Free Android GUI - Updated occasionally

drmindflip
Newbie
Posts: 7
Joined: Thu Jun 18, 2020 8:15 pm
Contact:

Re: How to create an image with both pictures and text

#5 Post by drmindflip » Fri Jun 19, 2020 9:53 am

Thanks so much for your help folks. I ended up using this:

Code: Select all

image an odd welcome = Composite (
    (750, 1050),
    (0, 0), Image("an odd welcome.png"),
    (60, 780), Text("card text"))
Should I be using Composite or LiveComposite? Finding it hard to get a clear idea of the difference

Post Reply

Who is online

Users browsing this forum: dGameBoy101b