Ejemplo n.º 1
0
 def __init__(self):
     Layer.__init__(self)
     self.config = Config()
     self.gallery = Gallery()
     self.schedule_interval(self.music_start, interval=7)
     self.intro_sound = load("music/sound_start.wav", streaming=False)
     self.intro_sound.play()
     self.is_event_handler = True
     background = Sprite(self.gallery.content["display"]["title"])
     self.optimal_scale = (
         self.config.window_width *
         self.display_pos_size["display_title"]["W"]) / background.width
     background.image_anchor = 0, 0
     background.scale = self.optimal_scale
     background.x = self.config.window_width * self.display_pos_size[
         "display_title"]["X"]
     background.y = self.config.window_height * self.display_pos_size[
         "display_title"]["Y"]
     self.left_margin = background.x
     self.bottom_margin = background.y
     self.optimal_width = background.width
     self.optimal_height = background.height
     self.add(background)
     place_holder_image = Sprite(self.gallery.content["screen"]["title"])
     place_holder_image.position = director.window.width / 2, director.window.height / 2
     place_holder_image.scale = self.optimal_scale
     place_holder_image.do(ScaleBy(5.2, duration=25))
     self.add(place_holder_image)
Ejemplo n.º 2
0
    def __init__(self):

        super(MainLayer, self).__init__()

        player = Sprite('sprites/Idle__000.png')
        player.scale = 0.2
        player.position = 120, 250

        # player.do(MoveBy((450, 0), 3))

        # player.do(Place((120, 400)))
        # player.do(RotateBy(120,0))
        # player.do(ScaleTo(1, 3))

        # player.do(Blink(10, 3))
        # player.do(Repeat(RotateBy(360, 1)))

        # caminarDerecha = MoveBy((450, 0), 2)
        # reiniciarPosicion = Place((120, 250))
        # player.do(caminarDerecha + reiniciarPosicion)

        # caminarDerecha = MoveBy((450, 0), 2)
        # rotar = RotateBy(360, 1) * 2
        # player.do(caminarDerecha | rotar)

        # player.do(Blink(10, 3) + Show())

        rotar = Repeat(RotateBy(360, 1))
        achicar = ScaleTo(0, 2.5)
        player.do(rotar | achicar)

        self.add(player)
Ejemplo n.º 3
0
 def set_sprite(self, args):
     for i in args:
         sd = Sprite(i)
         sd.do(Hide())
         self.add(sd)
         self.sprite_list.append(sd)
     self.sprite_list[self.direction].do(Show())
    def challenge(self, type, pos):
         hunter = Sprite(load_animation("resources/" + type + ".gif"), position = (random.randint(483, 826), 105))
         hunter.scale = minion_scale
         self.add(hunter)               
         hunter.do(MoveTo(pos, minion_move_time)) 

         return hunter
Ejemplo n.º 5
0
    def on_enter(self):
        super(Jive, self).on_enter()

        leftFoot = Sprite(self.image_left)
        rightFoot = Sprite(self.image_right)

        self.add(leftFoot)
        self.add(rightFoot)

        leftFoot.position = 400, 250
        rightFoot.position = 500, 250

        #left down
        down = MoveBy((0, -100), 1)
        #left.do(move)

        #left up and left
        left_up = MoveBy((-100, 100), 1)
        #left.do(move2)

        left = MoveBy((-100, 0), 1)

        right = MoveBy((100, 0), 1)


        leftFoot.do(Repeat(down + left_up + Delay(1) + left + Delay(2) + right + Delay(1) + right))
        rightFoot.do(Repeat(Delay(2) + left + Delay(1) + left + right + Delay(1) + right + Delay(1)))
Ejemplo n.º 6
0
class GhostLayer(CharLayer):

	def __init__(self, color="blue", vision=False):
		super().__init__()

		# create and add Sprites for ghost
		self.ghost1 = Sprite("images/" + color + "1.png")
		self.ghost2 = Sprite("images/" + color + "2.png")
		self.eyes = Sprite("images/eyesDown.png")

		self.sprites.append(self.ghost1)
		self.sprites.append(self.ghost2)
		self.sprites.append(self.eyes)

		self.charRect = Rect(40, 40, self.ghost1.width * 0.12, self.ghost1.height * 0.12)
		self.charRect.center = (40, 40);

		for ghost in self.sprites:
			self.add(ghost)
			ghost.position = self.charRect.center
			ghost.scale = 0.12


		# if this is my player add a vision field
		if vision:
			visionSprite = Sprite("images/vision.png")
			self.sprites.append(visionSprite)
			self.add(visionSprite)
			visionSprite.position = self.charRect.center


		# Animate ghost
		self.ghost1.do(Repeat(Blink(1, 0.3)))
Ejemplo n.º 7
0
    def check_queue(self, dt=0):
        width, height = cocos.director.director.get_window_size()

        image = fetch_image()
        sprite = Sprite(image)

        sprite.rotation = random.randint(-25, 25)

        end_scale = 1024.0 / image.width

        sw = int((image.width * end_scale) / 2)
        sh = int((image.height * end_scale) / 2)

        sprite.x = random.randint(sw, width - sw)
        sprite.y = random.randint(sh, height - sh)

        sprite.opacity = 0
        sprite.scale = end_scale * 1.5

        sprite.do(
            spawn(
                FadeIn(.2),
                AccelDeccel(ScaleTo(end_scale, duration=.4))) +
            Delay(15) +
            FadeOut(.5) +
            CallFunc(sprite.kill))

        self.z += 1
        self.add(sprite, z=self.z)
Ejemplo n.º 8
0
    def on_enter( self ):
        super(SpriteMoveTo,self).on_enter()

        sprite3 = Sprite( self.image )
        self.add(sprite3)
        sprite3.position = 320,300
        sprite3.do( MoveTo( (620,300), 4 ) )
Ejemplo n.º 9
0
class ParallaxBackground(Layer):
    def __init__(self, box, sprites, time, delay):
        super(ParallaxBackground, self).__init__()
        self.batch = cocos.batch.BatchNode()
        self.imgA = Sprite(sprites[0])      #Sprite A
        self.imgB = Sprite(sprites[1])      #Sprite B
        self.box = box          #(X, Y, W, H) Window Box (0 = X, 1 = Y, 2 = W, 3 = H)
        self.time = time        #in second

        w = box[2]
        h = box[3]

        self.imgA.position = (w/2, h/2)
        self.imgB.position = (w + (w /2), h/2)

        #point A to point B for image A
        A = MoveBy((-w, 0),time) + Place((w + w/2 ,h/2)) + MoveBy((-w, 0),time)
        B = MoveBy(( -w - w  , 0), time *2) + Place((w + (w /2), h/2))
        #IMAGE ANIMATION
        self.imgA.do(Repeat(A))
        self.imgB.do(Repeat(B))

        self.batch.add(self.imgA)
        self.batch.add(self.imgB)

        self.add(self.batch)
Ejemplo n.º 10
0
    def on_enter(self):
        super(SpriteMoveTo, self).on_enter()

        sprite3 = Sprite(self.image)
        self.add(sprite3)
        sprite3.position = 320, 300
        sprite3.do(MoveTo((620, 300), 4))
Ejemplo n.º 11
0
class Enemy():
    def __init__(self,x,y,deltaX,deltaY,t):
        image = pyglet.image.load("resources/bat1.png")
        image_gride = pyglet.image.ImageGrid(image,4,4,item_width=32,item_height=32)
        self.animation = pyglet.image.Animation.from_image_sequence(image_gride[13:17],0.1,True)
        self.sprite = Sprite(self.animation)
        self.sprite.position = x,y
        self.sprite.cshape = cm.AARectShape(
                        self.sprite.position,
                    self.sprite.width/3,
                self.sprite.height/3)

        przemieszczenie1 = deltaX,deltaY
        przemieszczenie2 = -deltaX,-deltaY

        ruch = MoveBy(przemieszczenie1,t)+MoveBy(przemieszczenie2,t)

        self.sprite.do(Repeat(ruch))

    def updateEnemy(self):
        self.sprite.cshape.center = self.sprite.position
        
        

    def returnSprite(self):
        return self.sprite
Ejemplo n.º 12
0
class Enemy(object):
    def __init__(self, game, pos, bonus_type=0):
        self._game = game
        self.is_alive = True
        self._life = constants.ENEMY_ARMOR
        self.bonus_type = bonus_type
        # Mouse pointer 'body'
        self.aim = pymunk.Body(1, 1)
        self.aim_shape = pymunk.Circle(self.aim, 1, (0, 0))
        self.aim_shape.layers = 0b000  # The 'aim' should not collide with any objects
        self.aim.position = pos
        # Enemy body
        mass = 3
        radius = 15
        inertia = pymunk.moment_for_circle(mass, 0, radius, (0, 0))
        self.body = pymunk.Body(mass, inertia)
        shape = pymunk.Circle(self.body, radius, (0, 0))
        shape.elasticity = 0.9
        shape.friction = 0.8
        shape.collision_type = 3
        self.shape = shape
        if not bonus_type:
            self.sprite = Sprite("enemy.png")
        elif bonus_type == constants.HEALTH_BONUS_TYPE:
            animation = pyglet.resource.animation("bonus_enemy_green.gif")
            self.sprite = Sprite(animation)
        elif bonus_type == constants.KILLALL_BONUS_TYPE:
            animation = pyglet.resource.animation("bonus_enemy_yellow.gif")
            self.sprite = Sprite(animation)
        self.sprite.do(Repeat(RotateBy(360, 2)))
        self.body.position = self.sprite.position = pos
        self.body.apply_force(-(self.body.mass + self.aim.mass) * game.space.gravity)
        # Connect aim and body with a DampedSpring - this should create the effect of flying through the air to the
        # player
        self.move = pymunk.constraint.DampedSpring(self.aim, self.body, (0, 0), (0, 0), 1, 600.0, 100)
        game.space.add(self.body, self.shape, self.aim, self.move)

    def update(self, dt):
        if not self.is_alive:
            self.sprite.opacity *= 0.91
        self.sprite.position = self.body.position

    def move_to(self, pos):
        self.aim.position = pos

    def take_damage(self, damage):
        self._life -= damage
        if self._life <= 0:
            self._life = 0
            self.is_alive = False
        elif self._life < 1500 and not self.bonus_type:
            self._game.remove(self.sprite)
            self.sprite = Sprite("enemy_damaged.png")
            self.sprite.do(Repeat(RotateBy(360, 1)))
            self._game.add(self.sprite)

    def suicide(self):
        self._life = 0
        self.is_alive = False
Ejemplo n.º 13
0
    def challenge(self, type, pos):
        hunter = Sprite(load_animation("resources/" + type + ".gif"),
                        position=(random.randint(483, 826), 105))
        hunter.scale = minion_scale
        self.add(hunter)
        hunter.do(MoveTo(pos, minion_move_time))

        return hunter
Ejemplo n.º 14
0
    def on_enter(self):
        super(SpriteJump, self).on_enter()
        sprite = Sprite(self.image)

        self.add(sprite)
        self.position = 120, 100

        sprite.do(JumpBy((400, 0), height=100, jumps=4, duration=3))
Ejemplo n.º 15
0
    def on_enter( self ):
        super(SpriteBezier,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        self.position = 120,100

        sprite.do( Bezier( foo.curva, 5 ) )
Ejemplo n.º 16
0
class SpriteLayer(ScrollableLayer):
    def __init__(self):
        super(SpriteLayer, self).__init__()

        # And, just like last time, we make our sprite and have it do the action we define
        self.sprite = Sprite("assets/img/grossini.png")
        self.add(self.sprite)
        self.sprite.do(GameAction())
Ejemplo n.º 17
0
    def on_enter(self):
        super(SpriteScale, self).on_enter()
        sprite = Sprite(self.image)

        self.add(sprite)
        sprite.position = 320, 200

        sprite.do(ScaleTo(10, 5))
Ejemplo n.º 18
0
class SpriteLayer(ScrollableLayer):
    def __init__(self):
        super(SpriteLayer, self).__init__()

        # And, just like last time, we make our sprite and have it do the action we define
        self.sprite = Sprite("assets/img/grossini.png")
        self.add(self.sprite)
        self.sprite.do(GameAction())
Ejemplo n.º 19
0
    def on_enter( self ):
        super(SpriteScale,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        sprite.position = 320,200

        sprite.do( ScaleTo( 10, 5 ) )
Ejemplo n.º 20
0
    def on_enter(self):
        super(SpriteRotate, self).on_enter()
        sprite = Sprite(self.image)

        self.add(sprite)
        self.position = 320, 200

        sprite.do(RotateBy(360, 2))
Ejemplo n.º 21
0
    def on_enter( self ):
        super(SpriteRotate,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        self.position = 320,200

        sprite.do( RotateBy( 360, 2 ) )
Ejemplo n.º 22
0
    def on_enter(self):
        super(SpriteBezier, self).on_enter()
        sprite = Sprite(self.image)

        self.add(sprite)
        self.position = 120, 100

        sprite.do(Bezier(foo.curva, 5))
Ejemplo n.º 23
0
    def on_enter( self ):
        super(SpriteJump,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        self.position = 120,100

        sprite.do( JumpBy( (400,0), height=100, jumps=4, duration=3 ) )
Ejemplo n.º 24
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite('grossini.png', (x / 2, y / 2), scale=0.1)
        self.add(self.sprite)
        self.sprite.do(ScaleBy(10, 2))
Ejemplo n.º 25
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()

        self.sprite = Sprite( 'grossini.png', (0,y//2)  )
        self.add( self.sprite )
        self.sprite.do( MoveBy( (x//2, 0) ) * 2 )
Ejemplo n.º 26
0
    def invoke(self, minion):
        mini = Sprite(load_animation("resources/" + minion + ".gif"),
                      position=spawn_place[minion])
        mini.scale = minion_scale
        self.add(mini)

        mini.do(
            MoveBy(minion_move_to[minion], minion_move_time) +
            CallFunc(mini.kill))
Ejemplo n.º 27
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()

        self.sprite = Sprite( 'grossini.png', (x/2, y/2) )
        self.add( self.sprite, name='sprite' )
        self.sprite.do( MoveBy( (x/2,y/2), 6 ) )
Ejemplo n.º 28
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite('grossini.png', (x // 4, y // 4))
        self.add(self.sprite)
        self.sprite.do(Bezier(path, 5))
Ejemplo n.º 29
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite("grossini.png", (x // 2, y // 2))
        self.add(self.sprite)
        self.sprite.do(Accelerate(Rotate(360, 10), 4))
Ejemplo n.º 30
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()

        self.sprite = Sprite( 'grossini.png', (x/2, y/2) )
        self.add( self.sprite )
        self.sprite.do( Delay(1) + Hide( ) )
Ejemplo n.º 31
0
class carlayer(ScrollableLayer):
    def __init__(self):
        super(carlayer, self).__init__()
        self.sprite = Sprite("assets/img/car.png")
        self.sprite.position = 200, 100
        self.sprite.max_forward_speed = 200
        self.sprite.max_reverse_speed = -100
        self.add(self.sprite)
        self.sprite.do(cardriver())
Ejemplo n.º 32
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite("grossini.png")
        self.add(self.sprite)
        self.sprite.do(MoveTo((x, y), 6))
Ejemplo n.º 33
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()

        self.sprite = Sprite( 'grossini.png', (x/2,y/2), scale = 0.1 )
        self.add( self.sprite )
        self.sprite.do( ScaleBy( 10, 2 ) + ScaleBy( 0.1, 2 )  )
Ejemplo n.º 34
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite('grossini.png', (x / 2, y / 2))
        self.add(self.sprite)
        self.sprite.do(Delay(1) + Hide())
Ejemplo n.º 35
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite('grossini.png')
        self.add(self.sprite)
        self.sprite.do(MoveTo((x, y), 6))
Ejemplo n.º 36
0
class Player(Layer):
    """
    Define a player for a normal Layer. 
    Use the arrow keys to change velocity
    N : position = (0, 0), velocity = (0, 0)
    up/down : modify y velocity
    left/right : modify x velocity
    """
    is_event_handler = True

    def __init__(self, img, driver=None, *args, **kwargs):
        super(Player, self).__init__(*args, **kwargs)
        w, h = director.get_window_size()
        self.title = cocos.text.Label('My Player', font_size=24, bold=True)
        self.title.position = (10, h - 40)
        self.add(self.title)

        self.doc = cocos.text.Label(self.__doc__,
                                    multiline=True,
                                    width=w - 20,
                                    anchor_y='top')
        self.doc.position = (10, h - 60)
        self.add(self.doc)

        self.status = cocos.text.Label('Status')
        self.status.position = (10, 50)
        self.add(self.status)

        self.sprite = Sprite(img, position=(w // 2, h // 2), scale=0.5)
        self.sprite.velocity = [10, 10]
        self.sprite.max_reverse_speed = -100
        self.sprite.max_forward_speed = 200
        if driver == None:
            driver = cocos.actions.Move()
        self.sprite.do(driver)
        self.add(self.sprite)

    def on_key_press(self, k, mod):
        w, h = director.get_window_size()
        vx, vy = self.sprite.velocity

        if k == key.N:
            self.sprite.position = w // 2, h // 2
            vx, vy = 0, 0
        elif k == key.RIGHT:
            vx += 10
        elif k == key.LEFT:
            vx -= 10
        elif k == key.UP:
            vy += 10
        elif k == key.DOWN:
            vy -= 10
        self.sprite.velocity = vx, vy

    def on_draw(self):
        self.status.element.text = 'pos=({:.0f}, {:.0f})'.format(
            self.sprite.x, self.sprite.y)
Ejemplo n.º 37
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite("grossini.png", (x // 4, y // 4))
        self.add(self.sprite)
        self.sprite.do(Bezier(path, 5))
Ejemplo n.º 38
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite("grossini.png", (0, y / 2))
        self.add(self.sprite)
        self.sprite.do(MoveBy((x / 2, 0)) + DoAction(Repeat(MoveBy((x / 2, 0)))))
Ejemplo n.º 39
0
class ScrollablePlayer(ScrollableLayer):
    """Define a player for a scrollable Layer."""
    def __init__(self, img, *args, **kwargs):
        super(ScrollablePlayer, self).__init__(*args, **kwargs)
        self.sprite = Sprite(img, position=(200, 100), scale=0.5)
        self.add(self.sprite)
        self.sprite.max_reverse_speed = -100
        self.sprite.max_forward_speed = 200
        self.sprite.do(DriveCar())
Ejemplo n.º 40
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()
        
        x,y = director.get_window_size()
        
        self.sprite = Sprite( 'grossini.png', (0,y/2)  )
        self.add( self.sprite )
        self.sprite.do( MoveBy( (x/2, 0) ) + Place( (x/2, y/3) ) + MoveBy( (x/2, 0) ) )
Ejemplo n.º 41
0
    def on_enter( self ):
        super(SpriteTrigger,self).on_enter()
        sprite = Sprite( self.image)
        self.add( sprite )
        sprite.position = 120,100
        
        move = MoveBy( (100,0), 2 )

        sprite.do( move + CallFunc( self.say_hello )  )
Ejemplo n.º 42
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite('grossini.png', (x / 2, y / 2))
        self.add(self.sprite)
        self.sprite.do(Reverse(Rotate(360, 5)))
Ejemplo n.º 43
0
    def on_enter(self):
        super(SpriteTrigger, self).on_enter()
        sprite = Sprite(self.image)
        self.add(sprite)
        sprite.position = 120, 100

        move = MoveBy((100, 0), 2)

        sprite.do(move + CallFunc(self.say_hello))
Ejemplo n.º 44
0
class Lama(ScrollableLayer):
    def __init__(self):
        super(Lama, self).__init__()

        self.sprite = Sprite(
            pyglet.image.load_animation("assets/img/lama_jump.gif"))
        self.sprite.position = 150, 100
        self.add(self.sprite)
        self.sprite.do(GameAction())
Ejemplo n.º 45
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()

        x,y = director.get_window_size()

        self.sprite = Sprite( 'grossini.png', (x/2, y/2) )
        self.add( self.sprite )
        self.sprite.do( Repeat ( Rotate( 360, 3 ) ) )
Ejemplo n.º 46
0
    def on_enter( self ):
        super(SpriteRepeat2,self).on_enter()
        sprite = Sprite( self.image)

        self.add( sprite )
        sprite.position = 120,100
        
        jump = JumpBy( (400,0), 100,4,3 )

        sprite.do( Repeat( jump + Reverse( jump ) ) )
Ejemplo n.º 47
0
    def on_enter( self ):
        super(SpriteRepeat,self).on_enter()
        sprite = Sprite( self.image)

        self.add( sprite )
        sprite.position = 120,100

        jump = JumpBy((400,0),100,4,3)

        sprite.do( Repeat( Place((120,100)) + jump ) )
Ejemplo n.º 48
0
    def on_enter( self ):
        super(SpriteBlink,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        sprite.position = (320,240)

        blink = Blink( 10, 2 )

        sprite.do( blink )
Ejemplo n.º 49
0
    def on_enter( self ):
        super(SpriteSpawn,self).on_enter()
        sprite = Sprite( self.image )

        self.add( sprite )
        sprite.position = 120,100

        jump = JumpBy( (400,0),100,4,5)
        rotate = RotateBy( 720, 5 )
        sprite.do( jump | rotate )
Ejemplo n.º 50
0
    def on_enter(self):
        super(SpriteBlink, self).on_enter()
        sprite = Sprite(self.image)

        self.add(sprite)
        sprite.position = (320, 240)

        blink = Blink(10, 2)

        sprite.do(blink)
Ejemplo n.º 51
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super( TestLayer, self ).__init__()
        
        x,y = director.get_window_size()
        
        self.sprite = Sprite('grossini.png', (0, y/2) )
        self.add( self.sprite  )
        mov = AccelDeccel( MoveBy( (x, 0 ), 4 ) )
        self.sprite.do( Repeat( mov + Reverse(mov) ))
Ejemplo n.º 52
0
    def on_enter(self):
        super(Bg, self).on_enter()
        sprite = Sprite(self.image)
        self.add(sprite)
        sprite.position = 320, 240
        sprite.do(ScaleTo(4,0))

        action = MoveTo((640, 480), 4) | ( ScaleTo(2,2) + ScaleTo(4,2) )

        sprite.do(action)
Ejemplo n.º 53
0
    def on_enter( self ):
        super(SpriteMoveBy,self).on_enter()

        sprite = Sprite( self.image )

        self.add( sprite )
        sprite.position = 320,200

        move = MoveBy( (150,0), 3 )
        sprite.do( move )
Ejemplo n.º 54
0
class TestLayer(cocos.layer.Layer):
    def __init__(self):
        super(TestLayer, self).__init__()

        x, y = director.get_window_size()

        self.sprite = Sprite("grossini.png")
        self.sprite.position = x / 2, y / 2
        self.add(self.sprite)
        self.sprite.do(cocos.actions.Rotate(360, 10))
Ejemplo n.º 55
0
    def on_enter(self):
        super(SpriteRepeat2, self).on_enter()
        sprite = Sprite(self.image)

        self.add(sprite)
        sprite.position = 120, 100

        jump = JumpBy((400, 0), 100, 4, 3)

        sprite.do(Repeat(jump + Reverse(jump)))
Ejemplo n.º 56
0
    def on_enter(self):
        super(SpriteRepeat, self).on_enter()
        sprite = Sprite(self.image)

        self.add(sprite)
        sprite.position = 120, 100

        jump = JumpBy((400, 0), 100, 4, 3)

        sprite.do(Repeat(Place((120, 100)) + jump))
Ejemplo n.º 57
0
class AddAction(Layer):
    """Display an actor and add a simple action."""
    def __init__(self):
        super(AddAction, self).__init__()
        w, h = director.get_window_size()
        self.sprite = Sprite('animals/dog-icon.png', position=(w // 2, h // 2))
        self.sprite.do(
            Repeat(Rotate(360, 2))
            | Repeat(ScaleBy(2, 1) + Reverse(ScaleBy(2, 1))))
        self.add(self.sprite)
Ejemplo n.º 58
0
    def __init__( self ):
        super( GrossiniLayer, self ).__init__()

        g = Sprite( 'grossini.png')
        g.position = (320,240)

        rot = RotateBy( 360, 4 )
        g.do( Repeat( rot + Reverse(rot) ) )

        self.add( g )
Ejemplo n.º 59
0
	def update_trail(self, trail_choice, player):
		if trail_choice == self.trail_list[0]:
			# Red trail
			trail = Sprite('ships/trail.png')
		elif trail_choice == self.trail_list[1]:
			# Blue trail
			trail = Sprite('ships/trail2.png')
		trail.position = player.position
		self.trail_batch.add(trail)
		trail.do(FadeOut(1) + CallFunc (self.trail_batch.remove, trail ) )			
Ejemplo n.º 60
0
    def on_enter(self):
        super(SpriteSpawn, self).on_enter()
        sprite = Sprite(self.image)

        self.add(sprite)
        sprite.position = 120, 100

        jump = JumpBy((400, 0), 100, 4, 5)
        rotate = RotateBy(720, 5)
        sprite.do(jump | rotate)