def init(self, browser): super(demo, self).init(browser) # 初始化 iphy2d.init() # debug 显示 iworld2d.init() iworld2d.camera_world_pos_center(0, 0) iphy2d.set_debug_draw(True) iworld2d.camera_world_scale(PHY_SCALE) # 取消重力 iphy2d.set_gravity((0, 0)) # 创建一个封闭空间 self.ground1 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(10, 1)) self.ground1.position = math3d.vector2(0, -10) self.ground1.body_type = iphy2d.STATIC_BODY self.ground1.category = F_EDGE self.ground2 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(10, 1)) self.ground2.position = math3d.vector2(0, 10) self.ground2.body_type = iphy2d.STATIC_BODY self.ground2.category = F_EDGE self.ground3 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1, 10)) self.ground3.position = math3d.vector2(-10, 0) self.ground3.body_type = iphy2d.STATIC_BODY self.ground3.category = F_EDGE self.ground4 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1, 10)) self.ground4.position = math3d.vector2(10, 0) self.ground4.body_type = iphy2d.STATIC_BODY self.ground4.category = F_EDGE # 创建物件 self.objs = []
def init(self, browser): super(demo, self).init(browser) # 初始化 iphy2d.init() # debug 显示 iworld2d.init() iworld2d.camera_world_pos_center(0, 0) iphy2d.set_debug_draw(True) iworld2d.camera_world_scale(PHY_SCALE) # 设置重力 iphy2d.set_gravity((0, 10.0)) # 创建一个地面 self.ground = iphy2d.body(iphy2d.POLYGON, math3d.vector2(35.0, 1)) self.ground.body_type = iphy2d.STATIC_BODY self.ground.position = math3d.vector2(0, 25) self.ground.resititution = 0.0 self.balls = [] # 弹力 restitutions = (0.0, 0.1, 0.3, 0.5, 0.75, 0.9, 1.0) for i in xrange(7): body = iphy2d.body(iphy2d.SPHERE, 1.0) body.body_type = iphy2d.DYNAMIC_BODY body.position = math3d.vector2(-10 + 3 * i, 20.0) body.restitution = restitutions[i] body.density = 1.0 self.balls.append(body)
def init(self, browser): super(demo, self).init(browser) # 初始化 iphy2d.init() # debug 显示 iworld2d.init() iworld2d.camera_world_pos_center(0, 0) iphy2d.set_debug_draw(True) iworld2d.camera_world_scale(PHY_SCALE) # 创建body # dynamic body # 创建一个body,默认形状为矩形 self.d_body = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1.0, 1.0)) self.d_body.body_type = iphy2d.DYNAMIC_BODY # dynamic body self.d_body.position = math3d.vector2(0.0, 0.0)# 起始位置 self.d_body.rot = 0.0 # 弧度 self.d_body.linear_velocity = math3d.vector2(-1.0, 1.0)# 线性速度 self.d_body.angular_velocity = math.pi# 角速度 # static body self.s_body = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1.0, 1.0)) self.s_body.body_type = iphy2d.STATIC_BODY # static body self.s_body.position = math3d.vector2(-10.0, 10.0)# 起始位置 self.s_body.rot = 0.0 # 弧度 # kinematic body self.k_body = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1.0, 1.0)) self.k_body.body_type = iphy2d.KINEMATIC_BODY # static body self.k_body.position = math3d.vector2(5.0, -5.0)# 起始位置 self.k_body.rot = 0.0 # 弧度 self.k_body.linear_velocity = math3d.vector2(-2.0, 2.0)# 线性速度 self.k_body.angular_velocity = math.pi# 角速度
def init(): global API, Sender, Sound iworld2d.init() cg_sound.init() API = iapi.API() Sender = API.sender Sound = cg_sound
def init(browser): global inst if inst is None: iworld2d.init() iworld3d.init() iworld3d.add_scene_to_layer2d(1) inst = demo() inst.init(browser)
def init(self, browser): super(demo, self).init(browser) iworld2d.init() # 3D场景在第三层 iworld3d.init() iworld3d.add_scene_to_layer2d(SCENE_LAYER) # 演示一个3D模型的生成 self.player = iworld3d.model3d("idemos/res/eggyolk/world3d/xiaodanhuang.gim", "xdh", SCENE_LAYER) self.player.pos = (0,0,-100)
def init(self, browser): super(demo, self).init(browser) # 初始化 iphy2d.init() # debug 显示 iworld2d.init() iworld2d.camera_world_pos_center(0, 0) iphy2d.set_debug_draw(True) iworld2d.camera_world_scale(PHY_SCALE) self.b1 = None self.b2 = None self.b3 = None
def init(): # 对物理模块初始化 iphy2d.init(30) iphy2d.set_gravity((0, 10)) global g_objs g_objs = {} # iworld2d模块初始化 iworld2d.init() # 生成背景 global background background = iworld2d.image2d("idemos/res/rabbit/world2d/txg/demo.txg|background", layer_id=0) background.pos = (0,0)
def init(self, browser): super(demo, self).init(browser) iworld2d.init() # 3D场景在第三层 iworld3d.init() iworld3d.add_scene_to_layer2d(SCENE_LAYER) # 演示一个3D模型的生成 self.player = iworld3d.model3d("idemos/res/eggyolk/world3d/xiaodanhuang.gim", "xdh", SCENE_LAYER) self.player.pos = (0,0,-100) # 创建一个公告板 self.bill = iworld3d.space_movie('idemos/res/eggyolk/gfx/bill.swf', True, pixel_unit=0.1, layer_id=SCENE_LAYER) self.bill.obj.render_level = -8 self.player.bind("cstop", self.bill) # 绑定到cstop的挂接点上 self.bill.billboard_type = True # 获取space_movie的movie属性,再设置变量 self.bill.movie.set_variable("name.text", "hello world!")
def init(self, browser): super(demo, self).init(browser) # 设置4个图层,0/1/3作为2D图层 # 图层2则是挂接一个3D场景,用于3D模型的演示 iworld2d.init(4) self.bgs = [] self.bgs.append(iworld2d.image2d("idemos/res/eggyolk/bg/bg_far.png", layer_id=0)) self.bgs.append(iworld2d.image2d("idemos/res/eggyolk/bg/bg_mid.png", layer_id=1)) self.bgs.append(iworld2d.image2d("idemos/res/eggyolk/bg/bg_near.png", layer_id=3)) self.bgs[1].pos = (0, 260) self.bgs[2].pos = (0, 580) # 3D场景在第三层 iworld3d.init() iworld3d.add_scene_to_layer2d(eggyolk2_const.SCENE_LAYER) self.create_objs()
def init(self, browser): super(demo, self).init(browser) iworld2d.init() # 3D场景在第三层 iworld3d.init() iworld3d.add_scene_to_layer2d(SCENE_LAYER) # 演示一个3D模型的生成 self.player = iworld3d.model3d("idemos/res/eggyolk/world3d/xiaodanhuang.gim", "xdh", SCENE_LAYER) self.player.pos = (0,0,-100) self.cam_rot = 0 # 增加三块石头 self.stones = [] for pos in ((0,0,-100),(20,30,-100),(-20,-30,-100)): stone =iworld3d.model3d("idemos/res/eggyolk/world3d/dalumian.gim", layer_id=SCENE_LAYER) stone.scale = (0.1,0.1,0.1) # 原来模型太大,需要缩小 stone.pos = pos self.stones.append(stone)
def init(self, browser): super(demo, self).init(browser) # 初始化 iphy2d.init() # debug 显示 iworld2d.init() iworld2d.camera_world_pos_center(0, 0) iphy2d.set_debug_draw(True) iworld2d.camera_world_scale(PHY_SCALE) # 设置重力 iphy2d.set_gravity((0, 10.0)) # 创建一个地面 self.ground = iphy2d.body(iphy2d.POLYGON, math3d.vector2(35.0, 1)) self.ground.body_type = iphy2d.STATIC_BODY self.ground.position = math3d.vector2(0, 15) # 斜面1,2,3 self.p1 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(13.0, 0.25)) self.p1.body_type = iphy2d.STATIC_BODY self.p1.position = math3d.vector2(-4.0, -5.0) self.p1.rot = 0.25 self.p1.friction = 0.2 self.p1.restitution = 0.0 self.p2 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(13.0, 0.25)) self.p2.body_type = iphy2d.STATIC_BODY self.p2.position = math3d.vector2(4.0, 2.0) self.p2.rot = -0.25 self.p2.friction = 0.2 self.p2.restitution = 0.0 self.p3 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(13.0, 0.25)) self.p3.body_type = iphy2d.STATIC_BODY self.p3.position = math3d.vector2(-4.0, 9.0) self.p3.rot = 0.25 self.p3.friction = 0.2 self.p3.restitution = 0.0 self.bricks = [] # 摩擦 frictions = (0.75, 0.5, 0.35, 0.1, 0.0) for i in xrange(5): body = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1, 1)) body.body_type = iphy2d.DYNAMIC_BODY body.position = math3d.vector2(-10 + 4 * i, -7.0) body.restitution = 0.0 body.density = 25.0 body.friction = frictions[i] self.bricks.append(body)
def init(self, browser): super(demo, self).init(browser) # 初始化 iphy2d.init() # debug 显示 iworld2d.init() iworld2d.camera_world_pos_center(0, 0) iphy2d.set_debug_draw(True) iworld2d.camera_world_scale(PHY_SCALE) # 设置重力 iphy2d.set_gravity((0, 10.0)) # 设置碰撞回调 iphy2d.set_first_collided_callback(body_collide) # 创建一个地面 self.ground = iphy2d.body(iphy2d.POLYGON, math3d.vector2(35.0, 1)) self.ground.body_type = iphy2d.STATIC_BODY self.ground.position = math3d.vector2(0, 15) self.tr1 = self.tr2 = self.box1 = self.box2 = self.circle1 = self.circle2 = None
def init(self, browser): super(demo, self).init(browser) iworld2d.init() self.movie = flashui.movie("idemos/res/d2mtl_effect/ui/ui.swf", True, True, flashui.SM_NoScale) self.movie.enable_keyboard = False self.image = iworld2d.image2d("idemos/res/d2mtl_effect/background.jpg") self.back = iworld2d.image2d("idemos/res/eggyolk/bg/bg_far.png") self.image.rlevel = 1 self.image.scale = (0.5, 0.5) self.image.pos = (1024 / 2, 768 / 2) self.image.key_point = (0, 0) txts = ["原图", ] ids = [0, ] for k, v in d2mtl_effect_cfg.config.iteritems(): ids.append(k) txts.append(v["name"]) self.movie.set_array("effect_ids", ids) self.movie.set_array("effect_menu.dataProvider", txts) self.set_effect(0)
def init(self, browser): super(demo, self).init(browser) # 设置4个图层,0/1/3作为2D图层 # 2则是挂接一个3D场景,用于3D模型的演示 iworld2d.init(4) self.bgs.append(iworld2d.image2d("idemos/res/eggyolk/bg/bg_far.png", layer_id=0)) self.bgs.append(iworld2d.image2d("idemos/res/eggyolk/bg/bg_mid.png", layer_id=1)) self.bgs.append(iworld2d.image2d("idemos/res/eggyolk/bg/bg_near.png", layer_id=3)) self.bgs[1].pos = (0, 260) self.bgs[2].pos = (0, 580) # 3D场景在第三层 iworld3d.init() iworld3d.add_scene_to_layer2d(SCENE_LAYER) # 演示一个3D模型的生成 self.player = iworld3d.model3d("idemos/res/eggyolk/world3d/xiaodanhuang.gim", "xdh", SCENE_LAYER) self.player.pos = (-8,48,-100) # 此位置刚好被前景层挡着 self.player.rotate_to_xyz(y=math.pi)
def init(api): API = api global text text = API.get_text_panel() text.set_text(TIPS) text.set_coord((30, 50)) iworld2d.init(4) global bgs bgs = [] bgs.append(iworld2d.image2d("tower/res/bg/bg_far.png", layer_id=0)) bgs.append(iworld2d.image2d("tower/res/bg/bg_mid.png", layer_id=1)) bgs.append(iworld2d.image2d("tower/res/bg/bg_near.png", layer_id=3)) bgs[1].pos = (0, 260) bgs[2].pos = (0, 580) iworld3d.init() iworld3d.add_scene_to_layer2d(tower_const.SCENE_LAYER) create_objs()
def init(self, browser): super(demo, self).init(browser) # 初始化 iphy2d.init() # debug 显示 iworld2d.init() iworld2d.camera_world_pos_center(0, 0) iphy2d.set_debug_draw(True) iworld2d.camera_world_scale(PHY_SCALE) # 取消重力 iphy2d.set_gravity((0, 0)) # 创建一个封闭空间 self.ground1 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(15, 1)) self.ground1.position = math3d.vector2(0, -15) self.ground1.body_type = iphy2d.STATIC_BODY self.ground1.resititution = 0.4 self.ground2 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(15, 1)) self.ground2.position = math3d.vector2(0, 15) self.ground2.body_type = iphy2d.STATIC_BODY self.ground2.resititution = 0.4 self.ground3 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1, 15)) self.ground3.position = math3d.vector2(-15, 0) self.ground3.body_type = iphy2d.STATIC_BODY self.ground3.resititution = 0.4 self.ground4 = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1, 15)) self.ground4.position = math3d.vector2(15, 0) self.ground4.body_type = iphy2d.STATIC_BODY self.ground4.resititution = 0.4 # 创建一个飞行器 self.body = iphy2d.body(iphy2d.POLYGON, math3d.vector2(1, 1)) self.body.destroy_fixture(0) # 将默认的删除 self.body.create_fixture(iphy2d.POLYGON, (math3d.vector2(2, 0), math3d.vector2(-1, 1), math3d.vector2(-1, -1)), 4.0) self.body.position = math3d.vector2(0, 2.0) self.body.angular_damping = 5.0 self.body.linear_damping = 0.1 self.body.allow_sleeping = False
def __init__(self): super(Eng, self).__init__() self.API = iapi.API_1_0() # itownsdk的api接口 Need fixed iworld2d.init() # 初始iworld2d print("Engine Init Success")
def init(self, browser): super(demo, self).init(browser) iworld2d.init() # 3D场景在第三层 iworld3d.init() iworld3d.add_scene_to_layer2d(SCENE_LAYER)
def init(browser): global inst if inst is None: iworld2d.init() inst = demo() inst.init(browser)