Adding more elements to a live composite sprite effectively

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
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Adding more elements to a live composite sprite effectively

#1 Post by namastaii »

This past week, I've been trying to make all these things happen without knowing how to do it lol Sorry, so I come here for help. I just want to know if there's a way that I can attach an 'affection bar' to a characters live composite so that way, whenever they are showing within a scene, their stat/affection bar follows them wherever they go and you don't have to write in each scene to show or hide their stat bar, you know? I did figure out a way .. but it's kind of awkward.

I added it right under the live composite and it places it where the character images begin instead of in the middle where I want it. I tried using xpos/ypos or xalign/yalign but it doesn't seem to move it. I tried moving the ui.bar down away from the live composite but then the bar doesn't show up at all.

Image

Here is the code for the character's live composite:

Code: Select all

def draw_samantha_flip(st, at): 
            return LiveComposite(
            (100, 630), # image size
            (0, 0), im.Flip(im.FactorScale("create_character/base_female1.png", .80, .80),horizontal=True),
            (0, 0), im.Flip(im.FactorScale("create_character/outfits/uniform_female_1.png", .80, .80),horizontal=True),
            #(0, 0), im.Flip(im.FactorScale("create_character/misc/dance_hoodie_%s.png"%(dance_hoodie), .80, .80),horizontal=True),
            #(0, 0), im.Flip(im.FactorScale("create_character/outfits/dance_outfit_%s.png"%(dance_outfit), .80, .80),horizontal=True),
            (0, 0), im.Flip(im.FactorScale("create_character/faces/samantha/%s.png"%(samantha_face), .80, .80),horizontal=True),
            (0, 0), im.Flip(im.FactorScale("create_character/hair_female/hair_samantha.png", .80, .80),horizontal=True),
            (0, 0), ui.bar(range=samantha_max,value=samantha_points,xmaximum=100,ymaximum=20,thumb=None,left_bar=Frame("create_character/full_bar.png"), right_bar=Frame("create_character/empty_bar.png")),
            ),.1
 

           
            #ui.bar(range=samantha_max,value=samantha_points,xmaximum=100,ymaximum=20,thumb=None,left_bar=Frame("create_character/full_bar.png"), right_bar=Frame("create_character/empty_bar.png"))
Another thing, when there is dialogue, the bar is showing (which is fine) but once I come across a menu, it like.. doubles it? I'm not sure why. It's just really buggy and hopefully there's a smoother way to do what I'm trying to accomlish.

Image


And like, when I put an xpos and ypos, it doesn't move the one it's supposed to-- it moves the bugged one. The one that shows up when there's a menu showing lol I'm so confused

Code: Select all

ui.bar(range=samantha_max,value=samantha_points,xmaximum=100,ymaximum=20,thumb=None,left_bar=Frame("create_character/full_bar.png"), right_bar=Frame("create_character/empty_bar.png"),xpos=300, ypos=50),
Image

neowired
Regular
Posts: 199
Joined: Mon Dec 01, 2008 2:33 pm
Contact:

Re: Adding more elements to a live composite sprite effectiv

#2 Post by neowired »

How about if, rather than try to add an ui.bar into your livecomposite, add your bar as a normal image

Code: Select all

def draw_samantha_flip(st, at):
            return LiveComposite(
            (100, 630), # image size
            (0, 0), im.Flip(im.FactorScale("create_character/base_female1.png", .80, .80),horizontal=True),
            (0, 0), im.Flip(im.FactorScale("create_character/outfits/uniform_female_1.png", .80, .80),horizontal=True),
            #(0, 0), im.Flip(im.FactorScale("create_character/misc/dance_hoodie_%s.png"%(dance_hoodie), .80, .80),horizontal=True),
            #(0, 0), im.Flip(im.FactorScale("create_character/outfits/dance_outfit_%s.png"%(dance_outfit), .80, .80),horizontal=True),
            (0, 0), im.Flip(im.FactorScale("create_character/faces/samantha/%s.png"%(samantha_face), .80, .80),horizontal=True),
            (0, 0), im.Flip(im.FactorScale("create_character/hair_female/hair_samantha.png", .80, .80),horizontal=True),
	         (0, 0), "create_character/empty_bar$d.png"%samantha_points,
            ),.1

make like, 10 pictures of your bar state (empty_bar1.png, empty_bar2.png, etc.), from 1-10
and then to change the bar you just change the the value of samantha_points between 1-10
you will have to draw the states of the bar yourself, but it may save you some trouble with trying to fit ui.bar inside the livecomposite? The bar becomes just another picture of the livecomposite, and you can adjust the position without issues that way?

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Adding more elements to a live composite sprite effectiv

#3 Post by namastaii »

Yeah...I could do that but that would be very tedious indeed... especially since I have multiple bars and multiple stats.

neowired
Regular
Posts: 199
Joined: Mon Dec 01, 2008 2:33 pm
Contact:

Re: Adding more elements to a live composite sprite effectiv

#4 Post by neowired »

If you want to get more fancy you could use a crop on in

Code: Select all

(0, 0), im.Crop("empty_bar.png", (0, 0, samanthaBarValue, 30)),
This way you only need one picture and the samanthaBarValue crops the image to that size

you can get a lot more fancy with this and do fun stuff like this for example

Code: Select all

(0,0), im.Crop(im.MatrixColor("emptyBar.png", im.matrix.hue(samBarHue)), (0,0,samBarValue,30)),
In this case not only can you crop the image by samanthaBarValue, but you can also change the bar's hue by samanthaBarHue. This allows you to easily use a single bar picture for multiple bars of different color.
Last edited by neowired on Sat Feb 06, 2016 1:29 am, edited 3 times in total.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Adding more elements to a live composite sprite effectiv

#5 Post by namastaii »

Ah, I have different colored images for the energy stats and whatnot but I don't really need them for the relationships on the sprites, though I just have one red one for when they are an enemy. But thanks, that's good to know. I'll try that one out.

neowired
Regular
Posts: 199
Joined: Mon Dec 01, 2008 2:33 pm
Contact:

Re: Adding more elements to a live composite sprite effectiv

#6 Post by neowired »

Btw, that second one should be

Code: Select all

 (0,0), im.Crop(im.MatrixColor("emptyBar.png", im.matrix.hue(samBarHue)), (0,0,samBarValue,30)),
i'll fix the above example, there was a syntax mistake.
Also, the crop can never be larger than the picture itself, or it will crash.

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Adding more elements to a live composite sprite effectiv

#7 Post by namastaii »

Yeah..I tried that out and all and I just get errors because it doesn't like the rest of the code my stuff is attached to, I guess. Oh well. blahhhh

User avatar
namastaii
Eileen-Class Veteran
Posts: 1350
Joined: Mon Feb 02, 2015 8:35 pm
Projects: Template Maker for Ren'Py, What Life
Github: lunalucid
Skype: Discord: lunalucid#1991
Soundcloud: LunaLucidMusic
itch: lunalucid
Location: USA
Contact:

Re: Adding more elements to a live composite sprite effectiv

#8 Post by namastaii »

It's okay. I decided to go a different route and it worked out :) Thank you everyone.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Andredron, Google [Bot]