# This code is so you can run the samples without installing the package
import sys
import os
sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))
#


import cocos
from cocos.director import director
from cocos.actions import FadeIn, FadeOut
from cocos.sprite import Sprite

import pyglet

class LayerToFade(cocos.layer.Layer):
    def __init__(self):
        super( LayerToFade, self ).__init__()
        
        x,y = director.get_window_size()
        
        self.sprite = Sprite( 'grossini.png', (x/2, y/2) )
        self.add( self.sprite )
        #self.sprite.do( FadeIn( 10 ) )


if __name__ == "__main__":
    # An easy case of Fading In a layer. Limitations: all scene parts that
    # draw before the ColorLayer are faded.
    director.init()
    # Notice the meaning of FadeIn and FadeOut are reversed 
    fadeable = cocos.layer.ColorLayer(0,0,0,255)
    fadeable.add(LayerToFade(), z=-1)
    # Screen will progress from black to full view of layer_to_fade
    fadeable.do(FadeOut(10))
    
    main_scene = cocos.scene.Scene(fadeable)
    director.run(main_scene)
