[SOLVED] SpriteManager() and im.Composite()

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
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

[SOLVED] SpriteManager() and im.Composite()

#1 Post by Milkymalk »

I want to dynamically create a sprite for a minigame using im.Composite. This is the code so far, and my problem is that apparently my sprite is blank.

(1) is how I get the game to display something at all.
(2) is a SIMPLE composite that already doesn't show anything.
(3) is how I want it to be, obviously it doesn't work either.

My guess is that SpriteManager() doesn't work with composites, but that would baffle me since im.Composite() can, at least in Ren'py code, used just like a file name in image declarations.

I know I can use animations I declared using normal Ren'py script in sprites, like this:

Code: Select all

    image blinkball:
        "gfx/ball_0.png"
        pause 0.1
        "gfx/ball_1.png"
        pause 0.1
So why not im.Composite() when it obviously returns a displayable?

Code: Select all

init python:
    class Game(object):
        class Sprite(object):
            def __init__(self, name):
                self.name = name
                
        class ShipClass(Sprite):
            allships = 'shmup/gfx/ships.png'
            shipcolor1 = 'shmup/gfx/shipcolor1.png'
            shipcolor2 = 'shmup/gfx/shipcolor2.png'
            def __init__(self, name, sprite, color, speed):
                self.speed = speed
#                self.sprite = allships            #(1)
                self.sprite = im.Composite(     #(2)
                    (0, 0),
                    (0, 0), self.allships)
#                self.sprite = im.Composite(   #(3)
#                    (0, 0),
#                    (0, 0), im.Crop(self.allships, (sprite*66, 0, 66, 64)), 
#                    (0, 0), im.MatrixColor(im.Crop(self.shipcolor1, (sprite*66, 0, 66, 64)), im.matrix.tint(color[0], color[1], color[2])))
                Sprite.__init__(name)
        
        # initiate spritemanager:
        def __init__(self):
            self.ships = SpriteManager()
            self.ship_sprites = [ ]
            self.ship_list = [ ]
            self.ship_list.append(self.ShipClass('Viper', 0, (1.0, 0.5, 0.0), 5))
            self.ship_sprites.append(self.ships.create(self.ship_list[0].sprite))
        
        def showships(self):
            renpy.show('ship', what=self.ships)
            self.ship_list[0].x = 0.5
            self.ship_list[0].y = 0.5

define e = Character('Eileen', color="#c8ffc8")

# The game starts here.
label start:
    $ shmup = Game()
    $ shmup.showships()
    e "You've created a new Ren'Py game."
Last edited by Milkymalk on Tue Jul 29, 2014 5:10 pm, edited 1 time in total.
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: SpriteManager() and im.Composite()

#2 Post by xela »

Your are supposed to use animations with im.Composite, try LiveComposite instead. I've also read somewhere that under modern Ren'Py, LiveComposite is always preferable due to better performance.

PS: "class ShipClass" (class statement is kind of a dead giveaway that Ship is a class) :P
Like what we're doing? Support us at:
Image

User avatar
Milkymalk
Miko-Class Veteran
Posts: 753
Joined: Wed Nov 23, 2011 5:30 pm
Completed: Don't Look (AGS game)
Projects: KANPEKI! ★Perfect Play★
Organization: Crappy White Wings
Location: Germany
Contact:

Re: SpriteManager() and im.Composite()

#3 Post by Milkymalk »

No, I'm not using an animation with im.Composite()... that was just an example what I already did with SpriteManager(). I'm actually cropping an image, tinting it, and then making a composite out of it to provide as displayable for a sprite in the sprite manager.

PS: Yes, ShipClass is more a personal reminder for me that it's a class :P

EDIT:
Using LiveComposite instead of im.Composite worked!
Crappy White Wings (currently quite inactive)
Working on: KANPEKI!
(On Hold: New Eden, Imperial Sea, Pure Light)

User avatar
xela
Lemma-Class Veteran
Posts: 2481
Joined: Sun Sep 18, 2011 10:13 am
Contact:

Re: SpriteManager() and im.Composite()

#4 Post by xela »

Milkymalk wrote: Using LiveComposite instead of im.Composite worked!
I guess that SpriteManager thing requires displayable, not images, but as long as it's working :)
Like what we're doing? Support us at:
Image

Post Reply

Who is online

Users browsing this forum: Bing [Bot]