当前位置: 首页>>代码示例>>Python>>正文


Python Image.reload方法代码示例

本文整理汇总了Python中kivy.uix.image.Image.reload方法的典型用法代码示例。如果您正苦于以下问题:Python Image.reload方法的具体用法?Python Image.reload怎么用?Python Image.reload使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在kivy.uix.image.Image的用法示例。


在下文中一共展示了Image.reload方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Planet

# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import reload [as 别名]
class Planet(FloatLayout):

    base_image = ObjectProperty(None)
    select_overlay = ObjectProperty(None)

    # TODO: complete this!?
    shadow_overlay = ObjectProperty(None)

    # LOGIC
    logic = ObjectProperty(None)

    def __init__(self, **kwargs):
        super(Planet, self).__init__(**kwargs)
        self.logic = App.get_running_app().logic
        self.size = (100, 100)
        # TODO: better way to acquire default textures paths
        self.base_image = Image(
            size_hint=(1, 1),
            pos_hint={'x': 0, 'y': 0},
            source='./media/textures/planets/sandyone.png',
            allow_stretch=True
        )

        self.select_overlay = Image(
            size_hint=(1.25, 1.25),
            pos_hint={'x': -0.125, 'y': -0.125},
            source='./media/textures/picked/scope.png',
            allow_stretch=True
        )

        self.add_widget(self.base_image)

    def on_size(self, instance, value):
        if self.base_image:
            self.base_image.size = value
            if self.select_overlay:
                newsize = (self.base_image.size[0] * 1.5, self.base_image.size[1] * 1.5)
                self.select_overlay.size = newsize
                self.select_overlay.center = self.center

    def select(self):
        self.select_overlay.center = self.center
        self.add_widget(self.select_overlay)

    def unselect(self):
        self.remove_widget(self.select_overlay)

    def set_base_image(self, source):
        self.base_image.source = source
        self.base_image.reload()
开发者ID:gandie,项目名称:PlanetAppV2,代码行数:52,代码来源:planet.py

示例2: Rocket

# 需要导入模块: from kivy.uix.image import Image [as 别名]
# 或者: from kivy.uix.image.Image import reload [as 别名]
class Rocket(Widget):
    default_y = dp(10)
    y = NumericProperty(dp(10))
    x = NumericProperty(Window.width/2 - Sizer.get_rocket_size()[0]/2)
    force = BooleanProperty(False)
    dead = False

    def __init__(self, **kwargs):
        super(Rocket, self).__init__(**kwargs)
        self.x = Window.width/2 - Sizer.get_rocket_size()[0]/2
        size = (resources.rocket['width'], resources.rocket['height'])

        with self.canvas:
            self.image = Image(source=resources.rocket['sprite2'],
                               pos=(self.x, self.y),
                               size=size)

    def move(self):
        if self.dead:
            if self.image.pos[0] > resources.rocket['width'] * -1 and\
                    self.image.pos[1] > resources.rocket['height'] * -1:
                self.image.pos = (self.image.pos[0] - dp(20),
                                  self.image.pos[1] - dp(20))
                self.image.size = (self.image.size[0] - dp(25),
                                   self.image.size[1] - dp(10))
            return

        if self.force:
            self.image.source = resources.rocket['sprite1']
            self.image.reload()
            # if self.image.pos[1] < (Window.height - self.default_y - 150):
            #     self.die()
            self.image.pos = (self.image.pos[0], self.image.pos[1] + Sizer.get_rocket_speed())
            self.pos = (self.image.pos[0], self.image.pos[1] + Sizer.get_rocket_speed())
        else:
            self.image.source = resources.rocket['sprite2']
            self.image.reload()

            self.image.pos = (self.image.pos[0], self.image.pos[1] - Sizer.get_rocket_speed())
            self.pos = (self.image.pos[0], self.image.pos[1] - Sizer.get_rocket_speed())

            if (
                self.image.pos[1] < (self.image.size[1] / 2) * -1 or
                self.image.pos[1] > Window.height + self.image.size[1]
            ):
                self.die()

    def die(self):
        self.dead = True

    def restart(self):
        self.dead = False
        self.default_y = dp(10)
        self.y = dp(10)
        self.x = Window.width/2 - Sizer.get_rocket_size()[0]/2
        self.force = False
        self.pos = (self.x, self.y)
        self.image.pos = (self.x, self.y)
        self.image.size = (resources.rocket['width'], resources.rocket['height'])
        self.image.source = resources.rocket['sprite2']
        self.image.reload()
        Block.reset_speed()
开发者ID:Vegasq,项目名称:moose-in-rocket,代码行数:64,代码来源:run.py


注:本文中的kivy.uix.image.Image.reload方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。