当前位置: 首页>>代码示例>>Python>>正文


Python CocosNode.add方法代码示例

本文整理汇总了Python中cocos.cocosnode.CocosNode.add方法的典型用法代码示例。如果您正苦于以下问题:Python CocosNode.add方法的具体用法?Python CocosNode.add怎么用?Python CocosNode.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cocos.cocosnode.CocosNode的用法示例。


在下文中一共展示了CocosNode.add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: Wobble

# 需要导入模块: from cocos.cocosnode import CocosNode [as 别名]
# 或者: from cocos.cocosnode.CocosNode import add [as 别名]
class Wobble(Layer):
    is_event_handler = True
    def __init__(self, position = (2,1), level = None):
        super(Wobble,self).__init__()
        self.level = level
        
        self.move_speed = 200
        self.status = "still"
        self.facing = "up"
        self.can_jump = True
        
        self.keyboard = {
            'LEFT'  :   False,
            'RIGHT' :   False,
            'SPACE' :   False,
            'UP'    :   False,
            'DOWN'  :   False,
        }
        self.sequences ={
            'still': [
                'blob_1.png',
                ],
            'walk': [
                'blob_1.png',
                'blob_2.png',
                'blob_3.png',
                'blob_4.png',
                'blob_5.png',
                'blob_6.png',
                'blob_7.png',
                'blob_6.png',
                'blob_5.png',
                'blob_4.png',
                'blob_3.png',
                'blob_2.png',
                'blob_1.png',
                ],
            'jump': [
                'blob_8.png',
                ],
            'death': [
                'death_1.png',
                'death_2.png',
                'death_3.png',
                'death_4.png'
            ]
        }
        
        self.tile_types = {
            'block-02': 'wall',
            'block-03': 'wall',
            'block-04': 'wall',
            'block-05': 'wall',
            'block-06': 'wall',
            'block-07': 'air',
            'block-08': 'air',
            'block-09': 'air',
            'block-10': 'air',
            'block-11': 'bad',
            'block-12': 'bad',
        }
        self.images = {}
        for animation in self.sequences:
            self.images[animation] = (pyglet.image.load("data/chars/wobble/"+filename) for filename in self.sequences[animation])
#            self.images[animation] = (pyglet.image.load(os.path.join("chars","wobble",filename)) for filename in self.sequences[animation])
        
        self.animations = {
            'still': Sprite(pyglet.image.Animation.from_image_sequence(self.images['still'], 1, True)),
            'walk' : Sprite(pyglet.image.Animation.from_image_sequence(self.images['walk'], 0.05, True)),
            'jump' : Sprite(pyglet.image.Animation.from_image_sequence(self.images['jump'], 1, True)),
#            'death': Sprite(pyglet.image.Animation.from_image_sequence(self.images['death'], 0.2, False)),
        }

#        print self.animations
#        self.sprite = Sprite(self.animations['still'])
        self.char = CocosNode()
        self.char.scale = 0.75
        self.set_grid_position(position)
        self.x = 0
        self.y = 0

        self.sprite = None
        self.add(self.char)
        
        self.set_animation()
#        self.sprite = Sprite(self.animations['jump'])
#        self.do(Repeat(Liquid(waves=5,amplitude=5)))
        self.do(Repeat(Waves(hsin=False)))
        self.do(Repeat(Waves(vsin=False,amplitude=5)))
        self.schedule(self.step)
        self.grid_type(1, 1)

    def set_grid_position(self,position):
        x = self.grid_x_to_x(position[0])
        y = self.grid_y_to_y(position[1])

        print "iniciando en ",x,",",y
        self.char.x = x
        self.char.y = y

#.........这里部分代码省略.........
开发者ID:HieuLsw,项目名称:blobjob,代码行数:103,代码来源:wobble.py


注:本文中的cocos.cocosnode.CocosNode.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。