Scroll does not work

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
Posts: 1
Joined: Sun Oct 07, 2018 1:39 am
Github: broelik
Skype: elik.aliev1

Scroll does not work

#1 Post by broelik » Sun Oct 07, 2018 1:43 am

Try to create custom displayable, but i had a problem with scrollbar.

Code: Select all

define e = Character('Эйлин', color="#c8ffc8")

init python:
    class BeatoMessageList(renpy.Displayable):
        WIDTH = 298
        HEIGHT = 529
        VIEWPORT_ID = 'beato_message_list'
        def __init__(self, **kwargs):
            super(BeatoMessageList, self).__init__(xysize=(self.WIDTH, self.HEIGHT), xfill=False, yfill=False, background='white', **kwargs)
            self.background_color = Color('#ffffff')
            # create VBox for messages
            self.message_box = renpy.display.layout.MultiBox(layout="vertical", style="vbox", many=True)
            self.side = renpy.display.layout.Side(style="side", positions='c r', many=True)
            # create viewport for messages VBox
            self.viewport = Viewport(child=self.message_box, draggable=True, mousewheel=True)
            # create ScrollBar with custom value
            self.scroll_bar = Bar(vertical=True, value=BeatoMessageScrollValue(self.viewport), style='vscrollbar')
            self.xpos = 0
            self.ypos = 0
            self.xsize = self.WIDTH
            self.ysize = self.HEIGHT
            self.x_offset = 0
            self.y_offset = 0
            # create test messages
            for i in range(100):
                self.message_box.add(Text("test %s" % (i)))
        def render(self, width, height, st, at):
            # bg_render = renpy.display.draw.solid_texture(width, height, self.background_color)
            # render ScrollBar
            bar_render = renpy.render(self.scroll_bar, 32, self.HEIGHT, st, at)
            # render content for ScrollBar
            side_render = renpy.render(self.side, self.WIDTH - 32, self.HEIGHT, st, at)
            # render self
            rv = renpy.Render(width, height, st, at)
            # rv.blit(bg_render, (0, 0))
            rv.blit(side_render, (0, 0))
            rv.blit(bar_render, (self.WIDTH - 32, 0))
            return rv
    # ScrollValue like a YScrollValue, but use viewport object instead of viewport ID
    class BeatoMessageScrollValue(YScrollValue):

        def get_adjustment(self):
            return self.viewport.yadjustment
# test screen
screen test:
    modal True
    zorder 2
    add BeatoMessageList()

# Игра начинается здесь:
label start:
    scene bg room
    $ renpy.call_screen('test')


Post Reply

Who is online

Users browsing this forum: Google [Bot]