Redrawing Transform in UDD [solved]

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
ChesStrategy
Regular
Posts: 96
Joined: Wed Jan 14, 2015 7:01 pm
Contact:

Redrawing Transform in UDD [solved]

#1 Post by ChesStrategy »

Trying to dabble in UDDs again; hastily wrote up the following code as a test; anyone know why the transform only took affect once (based on output from renpy.log())?
For anyone willing to help, you will need to specify your own "start_img" and a different layer.

Code: Select all

class Stage(renpy.Displayable):
    
    def __init__( self, stage_width, stage_height, transform_obj, **kwargs ):
        
        super( Stage, self).__init__(**kwargs)
        
        #self.single_actor = single_actor
        self.background = store.Solid( (200, 200, 200, 255) ) 
        
        self.children = [ self.background, transform_obj ]
        
        self.stage_width = stage_width
        self.stage_height = stage_height
        
    def render( self, width, height, st, at ):
        child_sizes = []
        child_renders = []
        
        for child in self.children:
            child_render = renpy.render( child, width, height, st, at )
            child_sizes.append( child_render.get_size() )
            child_renders.append( child_render )
        
        final_width = self.stage_width
        final_height = self.stage_height
        #for child_width, child_height in child_sizes:
        #    if child_width > self.stage_width:
        #        final_width = child_width
        #    if child_height > self.stage_height:
        #        final_height = child_height
        
        our_render = renpy.Render( final_width, final_height )
        for child_render in child_renders:
            our_render.blit( child_render, (0,0) )
            
        return our_render

    def visit( self ):
        return self.children

    def changeZOrder( self ):
        self.children = [ self.children[1], self.children[0] ]
        renpy.redraw( self, 0 )
            
    def event( self, ev, x, y, st ):
        
        renpy.redraw( self, 0 )
        
        for child in self.children:
            child.event( ev, x, y, st )

#### In script.rpy ####

def test_func( trans, st, at ):
        
        interp_xpos = st * 500
        interp_alpha = 1 - st 
        
        if st <= 1.0:
            setattr( trans, 'xpos', interp_xpos )
            setattr( trans, 'alpha', interp_alpha )
            
        renpy.log( "a: {}, xpos: {}".format( interp_xpos, interp_alpha ) )
        
        return None
    
    #test = Transform( child=start_img, function=test_func )
    test = At( start_img, Transform( function=test_func ) )     
    
    goal = renpyext_director.Stage( config.screen_width, config.screen_height, test )
    renpy.show( "something", at_list=[], what=goal, layer='character' ) 


ChesStrategy
Regular
Posts: 96
Joined: Wed Jan 14, 2015 7:01 pm
Contact:

Re: Redrawing Transform in UDD [solved]

#2 Post by ChesStrategy »

related to other solved issue

Post Reply

Who is online

Users browsing this forum: Lucyper