Animated images in screens

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
Eliont
Regular
Posts: 111
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Animated images in screens

#1 Post by Eliont »

Hello and good time of day.
How to create animations working inside of screens like:

Code: Select all

image ef gain_initiative:
    size (150, 150)
    "content/effects/gain_init/481-1.png" 
    align(0.5,0.5)
    pause 0.1
    "content/effects/gain_init/481-2.png"
    pause 0.1
    "content/effects/gain_init/481-3.png"
    pause 0.1
    "content/effects/gain_init/481-4.png"
    pause 0.1
    "content/effects/gain_init/481-5.png"
    pause 0.1
    "content/effects/gain_init/481-6.png"
    pause 0.1
    "content/effects/gain_init/481-7.png"
    pause 0.1
    "content/effects/gain_init/481-8.png"
    pause 0.1
    "content/effects/gain_init/481-9.png"
    pause 0.1
    "content/effects/gain_init/481-10.png"
    pause 0.1
    "content/effects/gain_init/481-11.png"
    pause 0.1
    "content/effects/gain_init/481-12.png"
    pause 0.1
    "content/effects/gain_init/481-13.png"
    pause 0.1
    "content/effects/gain_init/481-14.png"
    pause 0.1
    repeat
using python?

Old constructors - like

Code: Select all

self.animation = anim.Filmstrip('%s/animation/%s'%(classpath,fname), framesize, gridsize, delay, loop=false)
don't work with screens, they display only first frame.

Thanks in advance.

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Animated images in screens

#2 Post by trooper6 »

So your image is named 'ef' and it has an image tag of "gain_initiative"
Why did you do it that why? I'm curious.

Anyway, to answer your question, just add the image to the screen.

Code: Select all

screen yourscreen():
    add "ef gain_inititive"
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Eliont
Regular
Posts: 111
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Re: Animated images in screens

#3 Post by Eliont »

A question - how to create/define ATL images with python code?
like old anim.filmstrip

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Animated images in screens

#4 Post by trooper6 »

anim.filmstrip wasn't python code...it was renpy code. Just old renpy code that is now deprecated and replaced with ATL (see: http://www.renpy.org/wiki/renpy/doc/ref ... /Animation)
So...I'm not sure I understand the question.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

Eliont
Regular
Posts: 111
Joined: Thu Aug 06, 2009 6:51 am
Completed: Begin of Evangelion, SAO - Smile of the black cat, SAO - Project "Ceramic Heart", Time for Dragons
Location: Russia
Contact:

Re: Animated images in screens

#5 Post by Eliont »

This IS python code.

Problem is solved, thanks to Xela's custom anim.Filmstrip:

Code: Select all

    class FilmStrip(renpy.Displayable):
        def __init__(self, image, framesize, gridsize, delay, frames=None, loop=True, reverse=False, **kwargs):
            super(FilmStrip, self).__init__(**kwargs)
            width, height = framesize
            self.image = Image(image)
            cols, rows = gridsize
        
            if frames is None:
                frames = cols * rows
        
            i = 0
        
            # Arguments to Animation
            args = [ ]
        
            for r in range(0, rows):
                for c in range(0, cols):
        
                    x = c * width
                    y = r * height
        
                    args.append(Transform(self.image, crop=(x, y, width, height)))
        
                    i += 1
                    if i == frames:
                        break
        
                if i == frames:
                    break
                    
            # Reverse the list:
            if reverse:
                args.reverse()
                
                
            self.width, self.height = width, height
            self.frames = args
            self.delay = delay
            self.index = 0
            self.loop = loop
        
        def render(self, width, height, st, at):
            if not st:
                self.index = 0
            
            t = self.frames[self.index]
            
            if self.index == len(self.frames) - 1:
                if self.loop:
                    self.index = 0
                else:
                    return renpy.Render(0, 0)
            else:
                self.index = self.index + 1
            
            child_render = renpy.render(t, width, height, st, at)
            render = renpy.Render(self.width, self.height)
            render.blit(child_render, (0, 0))
            renpy.redraw(self, self.delay)
            return render
            
        def visit(self):
            return [self.image]     

Post Reply

Who is online

Users browsing this forum: Google [Bot]