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


Python Scene.add方法代码示例

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


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

示例1: main

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def main():
    director.init(**resources.settings['window'])
    scene = Scene()
    scene.add(MultiplexLayer(
        MainMenu(scene),
        LevelSelectMenu(),
        OptionsMenu(),
        ScoresLayer(),
        HelpLayer(),
        AboutLayer()
    ),
        z=1)
    director.set_show_FPS(resources.settings["general"]["showFps"])
    w, h = director.get_window_size()

    # Music - moved to resources
    # 1st Try - doesnt play anything
    # scene.load_music("assets/music.wav")
    # scene.play_music()

    # 2nd Try - static noise louder than music
    # music = pyglet.resource.media("assets/music.wav", streaming = True)
    # music.play()

    # 3rd Try - music stops after ca. 1 min (even when piece was longer)
    # and doesnt repeat as it should
#    music_player = pyglet.media.Player()
#    music = pyglet.resource.media("assets/music.wav", streaming = False)
#    music_player.queue(music)
#    music_player.eos_action = music_player.EOS_LOOP
    director.run(scene)
开发者ID:faide,项目名称:pyfense,代码行数:33,代码来源:pyfense.py

示例2: main

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def main():
    """
    test split layers
    """
    from cocos.scene import Scene
    from cocos.director import director

    director.init()

    window_size = director.get_window_size()
    window_rect = Rect(0, 0, *window_size)

    distance = window_size[0] * 3 / 4
    main_rect, rest_rect = split_horizontal(window_rect, distance)

    status_height = 80
    status_rect, menu_rect = split_vertical(rest_rect, status_height)

    main_layer = SplitLayer(main_rect)
    menu_layer = SplitLayer(menu_rect, color=(255, 255, 0, 255))
    status_layer = SplitLayer(status_rect, color=(255, 0, 255, 255))

    scene = Scene()
    scene.add(main_layer, z=0)
    scene.add(menu_layer, z=1)
    scene.add(status_layer, z=2)

    director.run(scene)
开发者ID:fisadev,项目名称:veronica-defense,代码行数:30,代码来源:split_layer.py

示例3: start_solitaire

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def start_solitaire(player_name, players):
    gamescene = Scene()
    gamelayer = IncantusLayer()
    gamescene.add(gamelayer, z=0, name="table")
    director.push(gamescene)
    #director.push(ZoomTransition(gamescene, 1.5))
    gamelayer.game_start(player_name, pyglet.clock.time.time(), players)
开发者ID:Incantus,项目名称:incantus,代码行数:9,代码来源:Incantus.py

示例4: start

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def start():
    director.init(width=CONF.window_width,
                  height=CONF.window_height,
                  caption=CONF.caption)
    scene = Scene()
    scene.add(menu.MainMenu(), z=1)
    director.run(scene)
开发者ID:kuainiao,项目名称:game_client,代码行数:9,代码来源:game.py

示例5: setup

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def setup(test=False, phase_source = None, train_end_calls = []):
    director.director.init(width=1056, height=700, caption='MatchBrain')
    scene = Scene()
    scene.add(MultiplexLayer(
        MainMenu(test, phase_source, train_end_calls),
    ), z = 1)
    return scene
开发者ID:jorenverspeurt,项目名称:MatchBrain,代码行数:9,代码来源:MatchBrain.py

示例6: reload_solitaire

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def reload_solitaire(replay_file):
    gamescene = Scene()
    gamelayer = IncantusLayer()
    gamescene.add(gamelayer, z=0, name="table")
    director.push(gamescene)
    #director.push(ZoomTransition(gamescene, 1.5))
    gamelayer.game_reload(replay_file)
开发者ID:Incantus,项目名称:incantus,代码行数:9,代码来源:Incantus.py

示例7: get_scene

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def get_scene():
    global keyboard, scroller
    keyboard = key.KeyStateHandler()
    director.window.push_handlers(keyboard)

    model = Model()

    world_layer = WorldMap(2000, 2000, model)
    scroller = cocos.layer.ScrollingManager()
    scroller.add(world_layer)

    car_layer = layer.ScrollableLayer()
    car = cocos.sprite.Sprite('car.png')
    car_layer.add(car)
    car.position = (200, 100)
    # car.max_forward_speed = 200
    # car.max_reverse_speed = -100
    car.max_forward_speed = 400
    car.max_reverse_speed = -200
    car.do(DriveCar(model))
    scroller.add(car_layer)

    scene = Scene()
    scene.add(scroller)

    return scene
开发者ID:FloydaGithub,项目名称:DontCrash,代码行数:28,代码来源:GameScene.py

示例8: new_game

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def new_game():
    director.init(resizable=False, width=1024, height=768)
    scene = Scene()
    scene.add(BackgroundLayer(), z=0)
    scene.add(MultiplexLayer(
        MainMenu(),
    ), z=1)
    director.run(scene)
开发者ID:aikikode,项目名称:pyhammerfight,代码行数:10,代码来源:menus.py

示例9: GameMenu

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
class GameMenu(Menu):
    def __init__(self):
        super(GameMenu, self).__init__()
        self.scene = Scene()
        self.scene.add(MultiplexLayer(MainMenu(), OptionsMenu(), KeyBindingMenu()), z=1)

    def start_game(self):
        director.run(self.scene)
开发者ID:Ecialo,项目名称:Codename-Parzalon,代码行数:10,代码来源:menu.py

示例10: menu_scene

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def menu_scene():
    scene = Scene()
    scene.add(BackgroundLayer('menu_backgroud.jpg'), z=0)
    scene.add(MultiplexLayer(
        MainMenu(),
        OptionsMenu()
    ), z=1)
    return scene
开发者ID:Dront,项目名称:asteroids,代码行数:10,代码来源:asteroids.py

示例11: start_game

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
 def start_game(self):
     scene = Scene()
     scene.add(MultiplexLayer(
                      MainMenu(),
                      OptionsMenu(),
                      HiScoresLayer(),
                      ), z=1)
     scene.add(BackgroundLayer(), z=0)
     director.push(ShuffleTransition(scene, 1.5))
开发者ID:mcgillij,项目名称:pygauntlet,代码行数:11,代码来源:gamelayers.py

示例12: main

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
def main():
    print(description)
    director.init( resizable=True, width=640, height=480 )
    scene_green = Scene()
    layer_green = ColorLayer(32,255,0,255)
    scene_green.add(layer_green)
    scene_green.do(ac.Delay(2.0) + ac.CallFunc(push_sequence_scene))
    # pyglet 1.1.4 needs this to timely pump actions 
    pyglet.clock.schedule(lambda dt: None)
    director.run(scene_green)
开发者ID:1414648814,项目名称:cocos,代码行数:12,代码来源:test_SequenceScene.py

示例13: on_win

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
 def on_win(self):
     Objects.reset_game()
     server = Objects.get_server(self.levelName)
     server.curLevel = self.level+1
     utils.play_sound("Enter.wav")
     game = Scene(server.map, server)
     game.add(ImageLayer(os.path.join("images", "backgrounds", "notebook-paper.png")), z=BACKGROUND_Z)
     director.push(game)
     menu_player.stop()
     self.game_started = True
开发者ID:david-abel,项目名称:noteworks,代码行数:12,代码来源:game.py

示例14: previous

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
    def previous():
        if SlidesManager.current_position == 0 or \
            SlidesManager.current_position-1 > len(SlidesManager.slides_pool):

            return

        SlidesManager.current_position-=1
        scene = Scene(Presentation())
        scene.add(SlidesManager.slides_pool[SlidesManager.current_position], z=1)
        director.push(scene)
开发者ID:flavioribeiro,项目名称:softwarefreedomdaycg,代码行数:12,代码来源:presentation.py

示例15: on_join_regular

# 需要导入模块: from cocos.scene import Scene [as 别名]
# 或者: from cocos.scene.Scene import add [as 别名]
    def on_join_regular(self):
        global game_controller
        game_controller = GameController()
        main_scene = Scene(
            game_controller.map, game_controller)
        director.push(main_scene)

        #adding a background layer that lies below all layers
        background_layer = ImageLayer(
            os.path.join("images", "backgrounds", "notebook-paper.png"))
        main_scene.add(background_layer, z=-1)
开发者ID:david-abel,项目名称:noteworks,代码行数:13,代码来源:chessmodemenu.py


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