コード例 #1
0
ファイル: build.py プロジェクト: johanlindberg/moonville
    def show_LVCS(self, show = True):
        if self.showing_LVCS == show:
            return

        # Toggle the LVCS button
        if show:
            self.LVCS_button_in.do(cocos.actions.FadeIn(0.25))
            self.LVCS_button_out.do(cocos.actions.FadeOut(0.25))
        else:
            self.LVCS_button_in.do(cocos.actions.FadeOut(0.25))
            self.LVCS_button_out.do(cocos.actions.FadeIn(0.25))

        self.showing_LVCS = show
        delay = 0.1

        # Reverse the "animation" when hiding
        items = self.LVCS_sprites
        if self.showing_LVCS == False:
            items = reversed(items)
            
        for item in items:
            frame, sprite, image = item
            
            if show:
                action = cocos.actions.FadeIn(1)
            else:
                action = cocos.actions.FadeOut(1)
                
            frame.do(cocos.actions.Delay(delay) + action)
            sprite.do(cocos.actions.Delay(delay) + action)

            delay += 0.05
コード例 #2
0
import cocos.director
import cocos.scene
import cocos.sprite
import cocos.layer
import cocos.actions as ac


class Hit(ac.IntervalAction):
    def init(self, duration=0.5):
        self.duration = duration

    def update(self, t):
        self.target.color = (255, 255 * t, 255 * t)


if __name__ == '__main__':
    cocos.director.director.init(caption='Actions 101')

    layer = cocos.layer.Layer()
    sprite = cocos.sprite.Sprite('tank.png', position=(200, 200))
    sprite.do(ac.MoveBy((100, 0), 3) + Hit() + ac.MoveBy((50, 0), 2))
    layer.add(sprite)

    scene = cocos.scene.Scene(layer)
    cocos.director.director.run(scene)
コード例 #3
0
ファイル: chapter3_01.py プロジェクト: zurfarosa/breakout
import cocos.director
import cocos.scene
import cocos.sprite
import cocos.layer
import cocos.actions as ac


class Hit(ac.IntervalAction):
    def init(self, duration=0.5):
        self.duration = duration

    def update(self, t):
        self.target.color = (255, 255 * t, 255 * t)


if __name__ == "__main__":
    cocos.director.director.init(caption="Actions 101")

    layer = cocos.layer.Layer()
    sprite = cocos.sprite.Sprite("tank.png", position=(200, 200))
    sprite.do(ac.MoveBy((100, 0), 3) + Hit() + ac.MoveBy((50, 0), 2))
    layer.add(sprite)

    scene = cocos.scene.Scene(layer)
    cocos.director.director.run(scene)