本文整理汇总了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)
示例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)
示例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)
示例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)
示例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
示例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)
示例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
示例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)
示例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)
示例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
示例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))
示例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)
示例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
示例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)
示例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)