本文整理汇总了Python中cocos.scene.Scene类的典型用法代码示例。如果您正苦于以下问题:Python Scene类的具体用法?Python Scene怎么用?Python Scene使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Scene类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_scene
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
示例2: test_6_on_pop_calls_on_enter_on_exit
def test_6_on_pop_calls_on_enter_on_exit(self):
global rec
scene0 = Scene()
scene1 = Scene()
def on_exit():
global rec
rec.append('on_exit_called')
def on_enter():
global rec
rec.append('on_enter_called')
scene0.on_enter = on_enter
scene1.on_exit = on_exit
rec = []
director.on_push(scene0)
# pyglet mockup 1 don't tickle on_draw, we call
# directly so the push / pop operation completes
director.on_draw()
director.on_push(scene1)
director.on_draw()
rec = []
director.on_pop()
director.on_draw()
assert rec[0]=='on_exit_called'
assert rec[1]=='on_enter_called'
示例3: start
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)
示例4: reload_solitaire
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)
示例5: start_solitaire
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)
示例6: setup
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
示例7: main
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)
示例8: main
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)
示例9: new_game
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)
示例10: GameMenu
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)
示例11: menu_scene
def menu_scene():
scene = Scene()
scene.add(BackgroundLayer('menu_backgroud.jpg'), z=0)
scene.add(MultiplexLayer(
MainMenu(),
OptionsMenu()
), z=1)
return scene
示例12: start_game
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))
示例13: previous
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)
示例14: main
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)
示例15: on_win
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