caves.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:caves 作者: mikaelho 项目源码 文件源码
def __init__(self, control, spec, *args, **kwargs):
    super().__init__(*args, **kwargs)

    self.control = control
    img_view = ui.ImageView(frame=self.bounds)

    img_view.image = ui.Image.named("playfields/caves of soukka.png")
    self.add_subview(img_view)

    self.menu = ui.View(frame=(
      30, self.height/2.1, self.width - 60, self.height/2 - 30
    ), corner_radius=10)
    #self.menu.background_color=(0,0,0,0.7)
    self.add_subview(self.menu)

    (_,_,w,h) = self.menu.frame
    def pick_map(sender):
      self.control.load_map(next_func=self.control.set_map_for_play)
    self.map_btn = ui.Button(title='Pick map', tint_color='white', background_color=self.menu_color, corner_radius=5, action=pick_map)
    self.menu.add_subview(self.map_btn)
    self.map_btn.frame = (0.05*w, 0.05*h, 0.55*w, 50)

    (title, action) = spec[2]
    self.menu_button(title, action, 50, (0.7*w, 0.05*h+25))
    (title, action) = spec[1]
    self.menu_button(title, action, 50, (0.9*w, 0.05*h+25))

    self.icons = {}
    self.small_icons = {}
    for i in range(len(self.control.icon_names)):
      icon =   ui.Image.named(self.control.icon_names[i]).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)
      small_icon = ui.Image.named(self.control.small_icon_names[i]).with_rendering_mode(ui.RENDERING_MODE_ORIGINAL)
      name = 'player'+str(i)
      self.icons[name] = icon
      self.small_icons[name] = small_icon
      btn = self.menu_color_button(
        name, self.control.colors[i], icon,
        (0.05*w + i*51, 0.25*h))
      if i > 0:
        self.toggle(btn)

    (title, action) = spec[0]
    self.menu_button(title, action, 50, (0.9*w, 0.25*h+25))

    #btn = self.create_button
    #self.set_menu('main', spec)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号