示例#1
0
  def __init__(self, assets):
    super(TestView, self).__init__()
    self.assets = assets

    # Get events 
    nwidget.events.clear(cocos.director.director.window)
    self.is_event_handler = True

    # Ui layer
    ui = CocosWidget()
    self.add(ui, z=1)

    # Load background
    bg = model.Background(self.assets)
    self.add(bg.node)

    # Load marker
    marker = model.Marker(self.assets)
    marker.node.position = 50, 50
    marker.node.scale = 0.25
    self.add(marker.node)

    # Snake instructions
    ui.widgets.append(
      nwidget.Label(
        text="Press arrow keys to change snake sprite",
        size=13,
        color=(255, 255, 255, 255)
      ).bounds(20, 150, 600, 180)
    )

    # Load snake
    snake = model.Snake(self.assets)
    snake.node.position = 50, 100
    snake.node.scale = 0.5
    self.add(snake.node)
    self.snake = snake

    # Path instructions
    ui.widgets.append(
      nwidget.Label(
        text="Press arrow keys to move path in that direction\nL to increase length of path, R to reset path",
        size=13,
        color=(255, 255, 255, 255)
      ).bounds(20, 300, 600, 425)
    )

    # Load a path and draw it
    self.path = model.Path()
    self.reset_path()
    self.path.move(x=-50)
    self.path.move(y=-30)
    self.path.move(x=-100)
    self.path.move(y=-20)
    self.path.move(y=-20)
    self.add(self.path)
示例#2
0
 def subheader(self):
   """ Return a themed label for a subheading """
   a = self.__assets
   rtn = nwidget.Label()
   rtn.color = (245, 245, 245, 255)
   rtn.text = "Header"
   rtn.font = a.resolve("deutsch.ttf")
   rtn.size = self.__font_size(text_type.SUBHEADER)
   return rtn
示例#3
0
 def header(self):
   """ Return a themed label for a heading """
   a = self.__assets
   rtn = nwidget.Label()
   rtn.color = (20, 20, 20, 255)
   rtn.text = "Header"
   rtn.font = a.resolve("aller.ttf")
   rtn.size = self.__font_size(text_type.HEADER)
   return rtn
示例#4
0
 def label(self):
   """ Return a themed label for a subheading """
   a = self.__assets
   rtn = nwidget.Label()
   rtn.color = (225, 225, 225, 255)
   rtn.text = "Label:"
   rtn.font = a.resolve("orotund.ttf")
   rtn.align = nwidget.align.RIGHT
   rtn.size = self.__font_size(text_type.LABEL)
   return rtn
示例#5
0
 def hint(self):
   """ Return a label for tiny hints """
   a = self.__assets
   rtn = nwidget.Label()
   rtn.color = (255, 255, 255, 255)
   rtn.text = "Label"
   rtn.font = a.resolve("orotund.ttf")
   rtn.align = nwidget.align.LEFT
   rtn.valign = nwidget.align.CENTER
   rtn.size = self.__font_size(text_type.SMALL)
   return rtn
示例#6
0
 def text(self):
   """ Return a label for text output """
   a = self.__assets
   rtn = nwidget.Label()
   rtn.color = (210, 210, 210, 255)
   rtn.text = "Label"
   rtn.font = a.resolve("orotund.ttf")
   rtn.align = nwidget.align.LEFT
   rtn.valign = nwidget.align.TOP
   rtn.size = self.__font_size()
   return rtn
示例#7
0
 def setup(self):
   return nwidget.Label(), nwidget.Assets()