Sha256: c4cebc0baa83c08c77b4a3d6ecf529e6cbf27d95e654e6b3650e572b948bbcae

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

class MenuLayer < Joybox::Core::Layer
  
  scene

  def on_enter

    layout_title
    layout_menu
  end


  def layout_title

    title_label = Label.new  text: 'Scenes', 
                             font_size: 50,
                             position: [Screen.half_width, Screen.height - 80],
                             color: Color.from_hex('#4AA419')

    self << title_label
  end


  def layout_menu

    MenuLabel.default_font_size = 40

    cocos2d_menu_item = MenuLabel.new  text: 'Cocos 2D', 
                                      color: Color.new(252, 253, 167), 
                                       do |menu_item|

      director.replace_scene(Cocos2DLayer.scene)
    end


    box2d_button = MenuLabel.new text: 'Box 2D',
                                color: Color.from_hex('82CCFB'),
                                 do |menu_item|

      director.replace_scene(Box2DLayer.scene)
    end


    cocos_motion_button = MenuLabel.new  text: 'Cocos Motion',
                                        color: Color.from_hex('FE7058'),
                                         do |menu_item|

      director.replace_scene(CocosMotionLayer.scene)
    end


    menu = Menu.new items: [cocos2d_menu_item, box2d_button, cocos_motion_button],
                     position: [Screen.half_width, (Screen.height - 80) / 2]

    menu.align_items_vertically

    self.add_child(menu, z: 1)
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
joybox-0.0.5 app/layers/menu_layer.rb
joybox-0.0.4 app/layers/menu_layer.rb
joybox-0.0.3 app/layers/menu_layer.rb