コード例 #1
0
ファイル: MyGame.py プロジェクト: ubuntunux/KivyProject
    def onEnter(self):
        # create screen
        gGameScreen.create_screen()
        # init fx manager
        gFxMgr.setLayer(gGameScreen.layer_fx)
        gFxMgr.setActive(True)
        # sprite manager
        gSpriteMgr.reset()

        # add star
        sprite1 = Sprite(
            size=(500, 500),
            vel=[500, 500],
            rotateVel=360,
            scaling=0.5,
            texture=gResMgr.getTex("star"),
            gravity=980,
            collision=True,
        )
        sprite2 = Sprite(
            pos=(200, 200),
            size=(500, 500),
            vel=[500, 500],
            rotateVel=180,
            scaling=0.5,
            texture=gResMgr.getTex("star"),
            gravity=80,
            collision=True,
        )
        gGameScreen.add_to_bg(sprite1)
        gGameScreen.add_to_bg(sprite2)

        # create a particle
        particleInfo = dict(
            loop=-1,
            texture=gResMgr.getTex("explosion"),
            fade=1,
            delay=Var(0.0, 1.0),
            rotateVel=Var(360.0),
            rotate=Var(0.0, 360),
            offset=Var((-20, 20), (-20, 20)),
            lifeTime=Var(0.5, 1.5),
            sequence=[4, 4],
            vel=Var([gVel * 0.1, gJump * 0.1], [-gVel * 0.1, gJump * 0.25]),
            scaling=Var(1.0, 2.5),
            gravity=Var(0.0),
        )
        gFxMgr.create_emitter("explosion1", particleInfo, 20)
        gFxMgr.create_emitter("explosion2", particleInfo, 20)

        gFxMgr.get_emitter("explosion1").play_particle_with(sprite1, True)
        gFxMgr.get_emitter("explosion2").play_particle_with(sprite2, True)
コード例 #2
0
ファイル: GameFrame.py プロジェクト: ubuntunux/KivyProject
 def start(self, callback_on_closed=None):
   self.callback_on_closed = callback_on_closed
   # init fx manager
   gFxMgr.setLayer(self.ui.layer_fx)
   gFxMgr.setActive(True)
   # sprite manager
   gSpriteMgr.reset()
   
   # add star
   for i in range(10):
     pos=(random.uniform(0, W), random.uniform(0, H))
     sprite = Sprite(pos=pos, size=(300,300), throwable=False, texture=gResMgr.getTexture('star'))
     self.ui.add_to_bg(sprite)
   
   # show ui and regist
   self.ui.show()
   gMyRoot.setTouchPrev(self.touchPrev)
   gMyRoot.regist(self)
コード例 #3
0
 def onEnter(self):
   # create screen
   gGameScreen.create_screen() 
   # init fx manager
   gFxMgr.setLayer(gGameScreen.layer_fx)
   gFxMgr.setActive(True)
   # sprite manager
   gSpriteMgr.reset()
   
   # add star
   sprite1 = Sprite(size=(500,500), vel=[500,500], rotateVel=360, scaling=0.5, texture=gResMgr.getTexture('star'), gravity=980, collision=True)
   sprite2 = Sprite(pos=(200,200), size=(500,500), vel=[500,500], rotateVel=180, scaling=0.5, texture=gResMgr.getTexture('star'), gravity=80, collision=True)
   gGameScreen.add_to_bg(sprite1)
   gGameScreen.add_to_bg(sprite2)
   
   # create a particle
   particleInfo = dict(loop=-1,texture=gResMgr.getTexture('explosion'), fade=1, delay=Var(0.0,1.0), rotateVel=Var(360.0), rotate=Var(0.0, 360), offset=Var((-20,20), (-20,20)),
     lifeTime=Var(0.5,1.5), sequence=[4,4], vel=Var([gVel*0.1, gJump*0.1], [-gVel*0.1, gJump*0.25]), scaling=Var(1.0, 2.5), gravity=Var(0.0))
   gFxMgr.create_emitter('explosion1', particleInfo, 20)
   gFxMgr.create_emitter('explosion2', particleInfo, 20)
   
   gFxMgr.get_emitter('explosion1').play_particle_with(sprite1, True)
   gFxMgr.get_emitter('explosion2').play_particle_with(sprite2, True)  
コード例 #4
0
ファイル: MyGame.py プロジェクト: ubuntunux/KivyProject
 def onExit(self):
     gSpriteMgr.reset()
     gFxMgr.setActive(False)
     gFxMgr.remove_emitters()
     gGameScreen.remove_screen()
コード例 #5
0
 def onExit(self):
   gSpriteMgr.reset()
   gFxMgr.setActive(False)
   gFxMgr.remove_emitters()
   gGameScreen.remove_screen()