def new_menu(): scene = cocos.scene.Scene() # create a colored background behind the menu color_layer = cocos.layer.ColorLayer(205, 133, 63, 255) # higher z values go on top of lower z values scene.add(MainMenu(), z=1) scene.add(color_layer, z=0) return scene
def create_scene(): """创建设置场景函数""" # 创建设置场景 scene = cocos.scene.Scene(SettingLayer()) # 添加主菜单 scene.add(MainMenu()) return scene
def new_menu(): scene = cocos.scene.Scene() color_layer = cocos.layer.ColorLayer(249, 224, 120, 255) scene.add(MainMenu(), z=1) scene.add(color_layer, z=0) sound.play() # scene center 280, 450 mainHumanPos = 750, 400 scene.add(humanRogo(mainHumanPos), z=0) # scene center 280, 450 startButtonPos = 1100, 300 scene.add(startBut(startButtonPos), z=0) # scene center 280, 450 exitButtonPos = 1100, 150 scene.add(exitBut(exitButtonPos), z=0) return scene
def new_menu(): scene = cocos.scene.Scene() color_layer = cocos.layer.ColorLayer(205, 133, 63, 255) scene.add(MainMenu(), z=1) scene.add(color_layer, z=0) return scene
sheep_action += Delay(2) wolf_action += Delay(2) cabbage_action += Delay(2) farmer_action += Place((x + 20, y + 50)) + MoveBy((t, 0), 2) \ + Place(settings.pos_of_farmer[boat_location]) boat_action += MoveBy((t, 0), 2) self.farmer.do(farmer_action) self.wolf.do(wolf_action) self.cabbage.do(cabbage_action) self.boat.do(boat_action) self.sheep.do(sheep_action) def who_move(self, xor): states = ('f', 'w', 's', 'c') moved = [] for (x, y) in zip(states, xor): if y == '1': moved.append(x) return moved if __name__ == '__main__': director.director.init(width=1024, height=768, caption='AI Yazlab') scene = scene.Scene() scene.add(BackgroundLayer(), z=0) scene.add(Animation(), z=0) director.director.run(scene)
def create_scene(): # 创建场景 scene = cocos.scene.Scene(HelpLayer()) # 添加主菜单 scene.add(MainMenu()) return scene
def create_scene(score): # 创建场景 scene = cocos.scene.Scene(GameOverLayer(score)) # 添加主菜单 scene.add(MainMenu()) return scene
self.time_elapsed = 0 self.sky = sqa.SVGnode("svgs/sky.svg",position=(800/2-20,600/2-20))#,anchor=(0,0)) self.add(self.sky) self.sun = sqa.SVGnode("svgs/sun.svg",position=(600,500)) self.add(self.sun) self.cloud = [] for n in xrange(10): x = random.uniform(0, 928) y = random.uniform(0, 728) z = random.uniform(1, 2) self.cloud.append(sqa.SVGnode("svgs/cloud.svg",position=(x,y),scale=z)) self.add(self.cloud[n], z) def on_enter(self): sqa.SVG_CacheNode.on_enter(self) def _step(self, dt): self.time_elapsed += dt for e in self.cloud: x,y = e.position x = (x+256 + 50*dt)%1200-256 e.position = (x,y) self.sun.rotation = 10 * math.sin(self.time_elapsed) director.init( width=800, height=600, resizable=False ) scene = cocos.scene.Scene() cache_node = SkyComposition() scene.add(cache_node) director.run( scene )